Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jqgrid更改单元格值并保持编辑模式_Jqgrid - Fatal编程技术网

jqgrid更改单元格值并保持编辑模式

jqgrid更改单元格值并保持编辑模式,jqgrid,Jqgrid,我在网格中使用内联编辑,我有一些情况需要更改列中单元格的值。我正在用setCell进行更改,效果很好。我的问题是,更改后,单元格将失去编辑模式,而行中的所有其他单元格都处于编辑模式。我想在更改单元格后将其保持在编辑模式 现在,我所做的是保存行,然后再次选择它,并在编辑模式下创建-但我认为这不是一个好的解决方案-有没有一种方法可以在更改时保持在编辑模式下 提前感谢。如果您需要实现所有处于编辑模式的依赖项单元格的行为,您必须手动修改单元格包含的功能。如果要修改的列的名称为“description”,

我在网格中使用内联编辑,我有一些情况需要更改列中单元格的值。我正在用setCell进行更改,效果很好。我的问题是,更改后,单元格将失去编辑模式,而行中的所有其他单元格都处于编辑模式。我想在更改单元格后将其保持在编辑模式

现在,我所做的是保存行,然后再次选择它,并在编辑模式下创建-但我认为这不是一个好的解决方案-有没有一种方法可以在更改时保持在编辑模式下


提前感谢。

如果您需要实现所有处于编辑模式的依赖项单元格的行为,您必须手动修改单元格包含的功能。如果要修改的列的名称为“description”,并且在另一个“code”列上使用“blur”事件,则可以执行以下操作

editoptions: {
    dataEvents: [
        {
            type: 'blur',
            fn: function(e) {
                var newCodeValue = $(e.target).val();
                // get the information from any source about the
                // description of based on the new code value
                // and construct full new HTML contain of the "description"
                // cell. It should include "<input>", "<select>" or
                // some another input elements. Let us you save the result
                // in the variable descriptionEditHtml then you can use

                // populate descriptionEditHtml in the "description" edit cell
                if ($(e.target).is('.FormElement')) {
                    // form editing
                    var form = $(e.target).closest('form.FormGrid');
                    $("#description.FormElement",form[0]).html(descriptionEditHtml);
                } else {
                    // inline editing
                    var row = $(e.target).closest('tr.jqgrow');
                    var rowId = row.attr('id');
                    $("#"+rowId+"_description",row[0]).html(descriptionEditHtml);
                }
            }
        }
    ]
}
编辑选项:{ 数据事件:[ { 键入:“blur”, fn:功能(e){ var newCodeValue=$(e.target).val(); //从任何来源获取有关 //基于新代码值的说明 //并构造“描述”的全新HTML包含 //单元格。它应包括“”“”或“” //其他一些输入元素。让我们保存结果 //在变量DescriptionEdit HTML中,可以使用 //在“描述”编辑单元中填充DescriptionEdit HTML if($(e.target).is('.FormElement')){ //表单编辑 var form=$(e.target.closest('form.FormGrid'); $(#description.FormElement),表单[0]).html(descriptionEditHtml); }否则{ //内联编辑 var行=$(e.target).closest('tr.jqgrow'); var rowId=row.attr('id'); $(“#”+rowId+“_description”,第[0]行。).html(descriptionEditHtml); } } } ] } 该代码可用于内联编辑和表单编辑


您可以找到的相关
元素的工作示例。

如果您需要实现所有处于编辑模式的相关单元格的行为,您必须手动修改单元格包含的功能。如果要修改的列的名称为“description”,并且在另一个“code”列上使用“blur”事件,则可以执行以下操作

editoptions: {
    dataEvents: [
        {
            type: 'blur',
            fn: function(e) {
                var newCodeValue = $(e.target).val();
                // get the information from any source about the
                // description of based on the new code value
                // and construct full new HTML contain of the "description"
                // cell. It should include "<input>", "<select>" or
                // some another input elements. Let us you save the result
                // in the variable descriptionEditHtml then you can use

                // populate descriptionEditHtml in the "description" edit cell
                if ($(e.target).is('.FormElement')) {
                    // form editing
                    var form = $(e.target).closest('form.FormGrid');
                    $("#description.FormElement",form[0]).html(descriptionEditHtml);
                } else {
                    // inline editing
                    var row = $(e.target).closest('tr.jqgrow');
                    var rowId = row.attr('id');
                    $("#"+rowId+"_description",row[0]).html(descriptionEditHtml);
                }
            }
        }
    ]
}
编辑选项:{ 数据事件:[ { 键入:“blur”, fn:功能(e){ var newCodeValue=$(e.target).val(); //从任何来源获取有关 //基于新代码值的说明 //并构造“描述”的全新HTML包含 //单元格。它应包括“”“”或“” //其他一些输入元素。让我们保存结果 //在变量DescriptionEdit HTML中,可以使用 //在“描述”编辑单元中填充DescriptionEdit HTML if($(e.target).is('.FormElement')){ //表单编辑 var form=$(e.target.closest('form.FormGrid'); $(#description.FormElement),表单[0]).html(descriptionEditHtml); }否则{ //内联编辑 var行=$(e.target).closest('tr.jqgrow'); var rowId=row.attr('id'); $(“#”+rowId+“_description”,第[0]行。).html(descriptionEditHtml); } } } ] } 该代码可用于内联编辑和表单编辑


您可以找到的从属
元素的工作示例。

如果值更改,则不会触发模糊,并且在不移动到其他单元格的情况下立即按enter键。所以最好是使用

editrules = new
{
custom = true,
custom_func = function( val, col ) { ... }
 },
并将此代码从模糊移动到自定义函数,如中所述

如果值被更改,并且在不移动到其他单元格的情况下立即按enter键,则不会触发模糊。所以最好是使用

editrules = new
{
custom = true,
custom_func = function( val, col ) { ... }
 },
并将此代码从模糊移动到自定义函数,如中所述

您能解释一下为什么需要保存处于编辑模式的单元格的内容吗。通常,如果用户在单元格中开始更改,他可以单击“Esc”放弃更改。如果用户单击“输入”,更改将被保存,但在这种情况下,该行在编辑模式下不会更多。您可能会使用另一种场景来保存数据。如果您解释场景并描述在哪个事件处理程序中使用
setCell
调用,我可以尝试为您的情况找到解决方法。@Oleg:我将尝试在我的网格中解释我的情况。我有两个单元格,其中一个是代码,另一个是代码说明。在代码单元“$(elem).blur(function()”中有在这个oblur函数中,我向提供描述的服务器发出一个ajax调用-然后我要做的是用我得到的值设置描述单元格,然后继续编辑我所在的行-我希望下一个单元格获得焦点并继续编辑。目前只有描述单元格失去编辑功能我想让它保持在编辑模式,你明白吗?你能解释一下为什么需要它来保存处于编辑模式的单元格的内容吗?通常,如果用户在单元格中开始更改,他可以单击“Esc”放弃更改。如果用户单击“Enter”更改将被保存,但在这种情况下,该行将不再处于编辑模式。可能您使用了另一种方案来保存数据。如果您解释该方案并描述在何处使用
setCell
调用