Easyui Change the DataGrid row background color according to some conditions

Source: Internet
Author: User

@author YHC

This tutorial will show you how to change the DataGrid component row style according to some conditions, whose listprice value is greater than 50 we will set the behavior in different colors.


View Demo

The Rowstyler function design of the DataGrid allows you to customize the line style, and the following code shows how to change the row 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= "no" >product id</th> <th field=  
            "ListPrice" "Width=" align= "right" >list price</th> <th field= "UnitCost" width= "no" align= "right" >unit cost  
            </th>  
            <th field= "attr1" width= ">Attribute</th> <th field=  
            " status "width=" 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) to pink (red) and the text color to blue (blue) according to some conditions;

Download Easyui Sample code: Easyui-datagrid-demo.zip




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.