jquery - jqgrid - Disable Header Check box (multiselect = true) if all rows are disable -
using jqgrid multiselect="true"
option. disabling rows , prevent selection based on flag status mentioned below
disable row(s) based on is_flagged = 1
//disable row flagged rowattr: function (item) { if (parseint(item.is_flagged) == 1) { return {"class": "ui-state-disabled ui-jqgrid-disablepointerevents"}; } }, //prevent selection of disabled rows beforeselectrow: function (rowid, e) { if ($(e.target).closest("tr.jqgrow").hasclass("ui-state-disabled")) { return false; // not allow select row } return true; // allow select row }
to disable header checkbox, implemented below code, disables header check box if 1 row disabled.
//disable header checkbox if rows disabled loadcomplete: function() { var grid = $("#grid"); var ids = grid.jqgrid('getdataids'); for(var i=0;i < ids.length;i++){ var rowid = ids[i]; var rowdata = jquery('#grid').jqgrid ('getrowdata', rowid); console.log(rowdata.submit_to_acc); if(rowdata.flag_status == 1){ $('tr.ui-jqgrid-labels').addclass('ui-state-disabled ui-jqgrid-disablepointerevents'); } } }
how can disable header check box (multiselect = true)
, when all
rows disabled i.e hasclass(ui-state-disabled)
?
jqgrid version = 4.6
jquery version = 1.7.2
i suggest save information whether row disabled or not inside of custom option of jqgrid. corresponding code on demo http://jsfiddle.net/olegki/aagxejj5/44/ uses
rowattr: function (item, rd, rowid) { var p = $(this).jqgrid("getgridparam"); if (rd.closed === "true" || rd.closed === true) { return {"class": "ui-state-disabled ui-jqgrid-disablepointerevents"}; } else { p.issomeenabled = true; } }, beforerequest: function () { var p = $(this).jqgrid("getgridparam"); p.issomeenabled = false; // reset filling }, loadcomplete: function () { var p = $(this).jqgrid("getgridparam"), $selall = $("#cb_" + this.id); if (p.issomeenabled) { $selall.removeclass("ui-state-disabled ui-jqgrid-disablepointerevents"); $selall.click(); // select // 1 need trigger click twice because of bugs // in case of usage old jquery version $selall.click(); // select $selall.prop("checked", true); } else { $selall.addclass("ui-state-disabled ui-jqgrid-disablepointerevents"); $selall.prop("checked", false); } }
i placed 1 enabled on second page, 1 can switch pages , see above code correctly work.
Comments
Post a Comment