jqGrid with checkbox in all columns -


i have jqgrid 6 columns, each 'checkbox' format. need of checkboxes' selected , unselected values based on column names. possible?

the first column provide option selecting remaining columns together. i'm unable add event listeners onclick or onselect when defining colmodel.

$("#grid").jqgrid({     url: '@url.action("access", "authorization")' + '?role=' + encodeuricomponent($('input#hidrole').val()),     datatype: 'json',     colnames: ["idaccess","permission", "all", "read", "add", "edit", "copy", "delete"],     colmodel: [         { name: 'idaccess', index: 'idaccess', width: 10, resizable: false, editable: false, hidden: true },         { name: 'permission', index: 'permission', width: 100, resizable: false, editable: false, hidden: false },         { name: 'all', index: 'all', editable: true, edittype: 'checkbox', editoptions: { value: "true:false" }, formatter: "checkbox", width: 50, resizable: false, formatoptions: { disabled: false }, onselect: "checkbox(this.value())" },         { name: 'isread_allowed', index: 'isread_allowed', editable: true, edittype: 'checkbox', formatter: "checkbox", editoptions: { value: "true:false" }, width: 50, resizable: false, formatoptions: { disabled: false }, onclick: "checkbox(checked,this.value)" },         { name: 'iscreate_allowed', index: 'iscreate_allowed', editable: true, edittype: 'checkbox', editoptions: { value: "true:false" }, formatter: "checkbox", width: 50, resizable: false, editable: true, formatoptions: { disabled: false }, onclick:"checkbox(event)"  },         { name: 'isupdateallowed', index: 'isupdateallowed', editable: true, edittype: 'checkbox', editoptions: { value: "true:false" }, formatter: "checkbox", width: 50, resizable: false, editable: true, formatoptions: { disabled: false }, },         { name: 'iscopy_allowed', index: 'iscopy_allowed', editable: true, edittype: 'checkbox', editoptions: { value: "true:false" }, formatter: "checkbox", width: 50, resizable: false, editable: true, formatoptions: { disabled: false } },         { name: 'isdeleteallowed', index: 'isdeleteallowed', editable: true, edittype: 'checkbox', editoptions: { value: "true:false" }, formatter: "checkbox", width: 50, resizable: false, editable: true, formatoptions: { disabled: false } },     ],     //rownum: 10,     //rowlist: [10],     pager: "#pager-json",                 autowidth: true,                 loadcomplete: function () {         var rowids = $("#grid").jqgrid('getdataids');         (var = 0; < rowids.length ; i++) {             var rowid = rowids[i];             var rowdata = jquery('#grid').jqgrid('getrowdata', rowid);             //below code check column if other columns have true in db. once checked attribute added not able uncheck             if ((rowdata['isread_allowed'] == "true") && (rowdata['iscreate_allowed'] == "true") && (rowdata['isupdateallowed'] == "true")                 && (rowdata['iscopy_allowed'] == "true") && (rowdata['isdeleteallowed'] == "true")) {                 var check = $("#" + rowid).find('input[type="checkbox"]');                 check.attr('checked', 'checked');             }         }         (var = 0; < rowids.length; i++) {             var rowdata = rowids[i];             if (rowdata['iscopy_allowed'] == null) {                 //alert("1");                 var checkbox = $("#grid" + rowdata.i);                 //checkbox.css("visibility", "hidden");                 checkbox.attr("disabled", true);             }         }     } }); 

you can use following selector of input elements:

jquery(".jqgrow td input", "#my_grid").each(function(){         jquery(this).unbind('click');         jquery(this).click(function(){             ...         }); }); 

the input element contained within td:

<td ... aria-describedby="my-column"><input type="checkbox" ...></td> 

you can use aria-describedby attributed on td element determine whether or not add click handler. like:

var col = jquery(this).parent().attr('aria-describedby'); if (col === "idaccess") {     // add handler here, etc... } 

you need go through similar exercise find checkboxes in particular row, although id might able restrict search, ie:

jquery(".jqgrow td input", "#" + my_id) 

alternatively, can assign each column unique class using classes colmodel option. example: classes:'col1'. simplify code setup click handlers, , may allow avoid using aria attribute @ all.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -