JqGrid setCell properties lost when sorting column -
just after editing row (mode inline) try change css properties of cells according new value.
typically : after editing of 1 row cell of row contains letter "d" update cell new css property : background-color: grey (using setcell method)
for use inline editing :
grid.jqgrid('navgrid',"#pager",{edit:false, add:false, del:false}); grid.jqgrid('inlinenav',"#pager",{edit:true, add:false, del:false, editparams: myeditparam});
for change background after editing use method aftersavefunc
myeditparam : ... aftersavefunc: function(rowid, datafromserver) { var rowdata = $("#list").jqgrid("getrowdata", rowid); (var key in rowdata) { if (rowdata[key] == "d") { key++; $("#list").jqgrid("setcell",rowid, key, "", {"background-color": "#ececec"} ); } } }, ...
this code works unfortunatly, when sort 1 column of grid setcell method not perserved ! (the cell lost it's background-color: grey)
does exist better method change background after editing in function of new value ?
thx ;)
if need change format/color/style of cell in column can value "d" should use cellattr
(see the answer or this one).
if need change format/color/style of row should use rowattr
(see the answer).
one thing important understand: neither cellattr
nor rowattr
called @ end of row editing. still have use aftersavefunc
callback.
the current code of aftersavefunc
seems me little strange. first of never had requirements mark value in any column of grid based on value ("d" in case). typically 1 need test specific column or columns value , mark cell or mark other cell in row.
in way 1 need typically not add class in value "d", remove class if value not "d".
i modified demo the answer support inline editing (one should use double-click start editing , press enter stop editing). the modified demo uses following code of aftersavefunc
additionally cellattr
used in old demo:
aftersavefunc: function (rowid) { var closed = $(this).jqgrid("getcell", rowid, "closed"), indexofcolumn; if (closed === "yes") { // add css classes cell used mark $(this).jqgrid("setcell", rowid, "name", "", "ui-state-error ui-state-error-text"); } else { // remove css classes cell used mark indexofcolumn = getcolumnindexbyname.call(this, "name"); $(this.rows.nameditem(rowid).cells[indexofcolumn]) .removeclass("ui-state-error ui-state-error-text"); } }
Comments
Post a Comment