JqxGrid: change row color based on column value

I answered several answers from this forum http://www.jqwidgets.com/jquery-widgets-documentation/documentation/jqxgrid/jquery-grid-cellsrendering.htm http://www.jqwidgets.com/community/topic/change- row-color-of-gridview /

Both are executed using the cellrendered cell event and can be applied to the same cell. How to get the value of one cell to change the color of another cell?

Or is there a way to change the background color of the entire line? Below is the code that I use to change the color of the same cell.

var cellsrenderer = function(row, column, value, defaultHtml) { var element = $(defaultHtml); element.css({ 'background-color': '#' + value }); return element[0].outerHTML; return defaultHtml; $("#jqxgrid").jqxGrid({ width: 1100, autorowheight: true, autoheight: true, source: dataAdapter, theme: 'classic', columns: [ { text: 'Job Number', dataField: 'jobNum' }, { text: 'Project Name', dataField: 'ProjName' }, { text: 'Hours', dataField: 'hrssum' }, { text: 'Project Type', dataField: 'Suffix' }, { text: 'color name', dataField: 'colorname', cellsrenderer: cellsrenderer } ] }); } 
+4
source share
1 answer

There are 2 more parameters in the cellrenderer that are passed by the jQWidgets network.

var cellsrenderer = function (row, column, value, defaultHtml, columnSettings, rowData) {

}

The final parameter, rowData, is a JSON object that contains the displayed string values. Therefore, if you have a column with a data field = firstname, you can write:

var firstName = rowData.firstname;

+7
source

Source: https://habr.com/ru/post/1480527/


All Articles