javascript - JQGRID - 禁用/启用文本框相对于 "edit dialog box(popup)"上的复选框状态的只读属性

标签 javascript jquery jqgrid

JQGRID - 在加载编辑弹出窗口时,如果未选中该复选框,则应将文本框设置为只读。如果选中复选框,则文本框应该是可编辑的。

最佳答案

尝试在 colModel 中使用 dataEvents

尝试像这样实现您的复选框字段...

colModel: [
{name: 'checkboxfield', sortable: true, sortorder: "ASC", sorttype: "string", editable: true,editoptions: {
                    value: "Active:Inactive", defaultValue: "Active",
                    dataEvents: [{
                        type: "change",
                        fn: function (e) {
                            var $this = $(e.target), columnName = "textboxfield",cellId;
                            if ($this.hasClass("FormElement")) {
                                cellId = columnName;
                            }
                            if ($this.is(":checked")) {
                                $("#" + $.jgrid.jqID(cellId)).prop("readonly", false);
                            }
                            else {
                                $("#" + $.jgrid.jqID(cellId)).prop("readonly", true);
                            }
                        }
                    }]
                }, edittype: "checkbox",   
         }, 
{name: 'textboxfield', sortable: true, sortorder: "ASC", sorttype: "string", editable: true, edittype: 'text'},
]

关于javascript - JQGRID - 禁用/启用文本框相对于 "edit dialog box(popup)"上的复选框状态的只读属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34605199/

相关文章:

jqGrid 将 colspan 应用于列标题

JQGrid - 我们如何制作自定义行详细信息

javascript - 如何在javascript中组合数组

javascript - 随 setTimeout 改变的变量值

javascript - 如何使用 Ajax 通过复选框将对象移动到另一个范围?

jquery - GON - 在 js.erb + Rails 5 中没有获得值(value)

jquery - Html单选按钮选择

jquery - JQUERY 中用于加载 JQGRID 的选项卡

javascript - 如何将一个 div 添加到 DOM 并稍后再拾取它

javascript - jQuery 图像交换和动画不起作用