简体   繁体   中英

JQGRID - disable/enable textbox's readonly property with respect to checkbox status on “edit dialog box(popup)”

JQGRID - On load of edit popup, a Textbox should be made readonly if the checkbox is unchecked . The textbox should be editable if checkbox is checked.

Try to use dataEvents in colModel.

try to implement your checkboxfield like this ...

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'},
]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM