jqgrid 更改单元格值并保持编辑模式 [英] jqgrid change cell value and stay in edit mode

查看:17
本文介绍了jqgrid 更改单元格值并保持编辑模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网格中使用内联编辑,在某些情况下我想更改列内单元格的值.我正在使用 setCell 对其进行更改,并且效果很好.我的问题是,更改后的单元格失去了它的编辑模式,而该行的所有其他单元格都处于编辑模式.我想在更改后将单元格保持在编辑模式.

I'm using inline editing in my grid , I have some cases which i want to change the value of a cell inside a column. I'm changing it with setCell ,and it works good. my problem is that after the change the cell losts it's edit mode while all other cells of the row are in edit mode. I want to keep the cell in edit mode after i changed it.

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

for now what i did is saved the row and then selected it again and made in in edit mode - but i don't think it is a good solution - Is there a way to keep in edit mode while changin it?

提前致谢.

推荐答案

如果你需要实现依赖单元格的行为,这些单元格都处于编辑模式,你必须手动修改单元格包含的 jQuery.html 函数为例.如果您要修改的列的名称具有名称description",并且您在另一个code"列上使用了blur"事件,那么您可以执行以下操作

If you need to implement the behavior of dependency cells which are all in the editing mode you have to modify the cell contain manually with respect of jQuery.html function for example. If the name of the column which you want to modify has the name "description", and you use 'blur' event on another "code" column then you can do about the following

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);
                }
            }
        }
    ]
}

该代码适用于内联和表单编辑.

The code will work for both inline and form editing.

相关<select>元素的工作示例这里.

这篇关于jqgrid 更改单元格值并保持编辑模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆