Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery EasyUI DataGrid - Conditionally Setting Row Background Color

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 IDProduct IDList PriceUnit CostAttributeStauts


    $('#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.

Download the jQuery EasyUI example

jeasyui-datagrid-datagrid18.zip