How to prevent selecting a dropdown based on cell value condition in Jqgrid -


i trying highlight cells in red whichever values not matching predefined values , 1. want count of red cells in each row in column error_cells_count,now in demo page have manually entered count 2. , want prevent user selecting dropdown in status column if row has red cells. have managed highlight cells. please red cells count in error_cells_count column , prevent user selecting dropdown. demo page http://jsfiddle.net/h8lzgh7d/27/ jqgrid version version 4.14.0 , kindly suggest if possibilities have predefined dictionary , correct red cells automatically replacing red cell values dictionary value

first of i'd recommend use cellattr set css properties on cell. seconds can use editable defined function allow editing cell depend on custom criteria (see the wiki article more details).

the fixed demo following https://jsfiddle.net/olegki/h8lzgh7d/30/. uses following code:

var hilightcolorcell=["purple","pink","green"]; var hilightcahractercell=["character 1","character 2","character 3"];  jquery("#rowed5").jqgrid({     datatype: "local",     shrinktofit: false,     data: mydata,     height: 320,     autowidth:true,     colnames:['rowid','error_cells_count','status','note','color_name','character_name','variant id'],     colmodel: [          {name:'id', width:55, sorttype:"int",align:"center",frozen:true},         {name:'error_cells_count', width:100, sorttype:"int",             align:"center",frozen:true,             cellattr: function (rowid, cellvalue) {                 if (cellvalue != null) {                     var value = parseint(cellvalue, 10);                     return " class='" +                         (value > 0 ? "redcells" : "greencells") +                         "'";                 }             }},         {name:'status', width:100,             editable: function (options) {                 var item = $(this).jqgrid("getlocalrow", options.rowid);                 return (item.error_cells_count == null || item.error_cells_count <= 0) &&                     $.inarray(item.color_name, hilightcolorcell) >= 0 &&                     $.inarray(item.character_name, hilightcahractercell) >= 0;             },             edittype:"select",editoptions:{value:"approve:approve"}},         {name:'note',width:100, sortable:false,editable: true,             edittype:"textarea", editoptions:{rows:"2",cols:"10"}},         {name:'color_name',             cellattr: function (rowid, cellvalue) {                 if ($.inarray(cellvalue, hilightcolorcell) < 0) {                     return " class='redcells'";                 }             }},         {name:'character_name',             cellattr: function (rowid, cellvalue) {                 if ($.inarray(cellvalue, hilightcahractercell) < 0) {                     return " class='redcells'";                 }             }},         {name:'v_id'}     ],     cmtemplate: { width:110 }, // define default properties colmodel     editurl: "functions.php",     celledit: true,     cellsubmit: 'remote',     cellurl: 'functions.php',     searching: {         stringresult: true,         searchonenter: false,         defaultsearch : "cn"     } }).jqgrid("setfrozencolumns")     .jqgrid("filtertoolbar"); 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -