jQuery EasyUI Data Grid - conditions set row background color

This tutorial will show you how to change the Line Style Data Grid (datagrid) assembly according to a number of conditions. When listprice value is greater than 50, we will set a different color for the row.

Designed for data grid (datagrid) of rowStyler function is to allow you to customize the line styles. The following code shows how to change the line style:

	<Table id = "tt" title = "DataGrid" style = "width: 600px; height: 250px"
			url = "data / datagrid_data.json"
			singleSelect = "true" fitColumns = "true">
		<Thead>
			<Tr>
				<Th field = "itemid" width = "80"> Item ID </ th>
				<Th field = "productid" width = "80"> Product ID </ th>
				<Th field = "listprice" width = "80" align = "right"> List Price </ th>
				<Th field = "unitcost" width = "80" align = "right"> Unit Cost </ th>
				<Th field = "attr1" width = "150"> Attribute </ th>
				<Th field = "status" width = "60" align = "center"> Stauts </ th>
			</ Tr>
		</ Thead>
	</ Table>
	$ ( '# Tt'). Datagrid ({
		rowStyler: function (index, row) {
			if (row.listprice> 50) {
				return 'background-color: pink; color: blue; font-weight: bold;';
			}
		}
	});

As you can see, we set the background-color (background color), according to some conditions for the pink (pink), set the text color to blue (blue).

Download jQuery EasyUI examples

jeasyui-datagrid-datagrid18.zip