jQuery EasyUI DataGrid - Conditionally Setting Row Background Color
This tutorial will show you how to change the row style of the datagrid component based on certain conditions. When the listprice value is greater than 50, we will set a different color for that row.
The datagrid's rowStyler function is designed to allow you to customize the row style. The following code shows how to change the row style:
Item ID
Product ID
List Price
Unit Cost
Attribute
Stauts
$('#tt').datagrid({
rowStyler:function(index,row){
if (row.listprice>50){
return 'background-color:pink;color:blue;font-weight:bold;';
}
}
});
As you can see, based on certain conditions we set the background-color to pink and the text color to blue.