Categories | Question details Back To List | ||
addRowClass and removeRowClass We had a need to adjust the class of a given row without actually selecting it. We could have used the "setRowColor", but all of our colors are contained in dynamic stylesheets. Rather than try and pull the colors from the stylesheet object, we wrote the following and added it into dhtmlxgrid.js just after line 41 (though there is likely a better location for them...) Code: this.addRowClass = function(row_id,c){if(c){var i=this.getRowIndex(row_id);if(i>-1){if(this.rowsCol[i]._css){var s=this.rowsCol[i]._css.split(" ");for(var x=0;x<s.length;x++){if(s[x]==c)var r=true;}if (!r){this.rowsCol[i]._css+=" "+c}}else{this.rowsCol[i]._css=" "+c;}this._fixAlterCss(i-1);}}}; this.removeRowClass = function(row_id,c){if(c){var i=this.getRowIndex(row_id);if(i>-1){if(this.rowsCol[i]._css){var s=this.rowsCol[i]._css.split(" ");this.rowsCol[i]._css="";for(var x=0;x<s.length;x++){if(s[x]!=c)this.rowsCol[i]._css+=" "+s[x];}this._fixAlterCss(i-1);}}}}; Use: mygrid.addRowClass("myRow","blueBG"); // Adds "blueBG" class to grid row id="myRow" mygrid.removeRowClass("myRow","blueBG"); // Removes "blueBG" class from grid row id="myRow" We've tested these in IE6/7 in grids which use alternating lines of color (our only use-case.) It may require tweaking to work in other browsers or grid formats. Hopefully others will find this useful! Answer posted by Support on Jun 27, 2008 03:18 The provided functionality may be really usefull. But it will work for plain mode only, it will not work for grid in paging or srnd_modes ( in such cases accessing row by index is not safe ) In any case - thanks for provided code, we will look how it can be extended to work in all modes and incorporate such funcitonality in next version of dhtmlxgrid. |