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

jQuery EasyUI DataGrid - Formatting Columns

jQuery EasyUI DataGrid - Formatting Columns

The following example formats column data in an easyui DataGrid using a custom column formatter; if the price is less than 20, the text is turned red.

To format a DataGrid column, we need to set the formatter property, which is a function. This formatting function takes three parameters:

Create the DataGrid



    

        

            

                

                

                

                

                

                

            

        

    
Item IDProduct IDList PriceUnit CostAttributeStauts

Note that the 'listprice' field has a 'formatter' property that indicates the formatting function.

Write a formatter function



    function formatPrice(val,row){

        if (val < 20){

            return '('+val+')';

        } else {

            return val;

        }

    }

Download the jQuery EasyUI example

jeasyui-datagrid-datagrid7.zip