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

jQuery EasyUI DataGrid - Creating a Custom View

jQuery EasyUI DataGrid - Creating a Custom View

In different situations, you may need to apply a more flexible layout to the datagrid. For users, the Card View is a good choice. This tool can quickly fetch and display data in the datagrid. In the datagrid header, you can sort data simply by clicking a column header. This tutorial will show you how to create a custom Card View.

Create a Card View (Card View)

Inheriting from the datagrid's default view is a good way to create a custom view. We will create a Card View to display some information for each row.



    var cardview = $.extend({}, $.fn.datagrid.defaults.view, {

        renderRow: function(target, fields, frozen, rowIndex, rowData){

            var cc = [];

            cc.push('');

            if (!frozen){

                var aa = rowData.itemid.split('-');

                var img = 'shirt' + aa[1] + '.gif';

                cc.push('');

                cc.push('
');                 for(var i=0; i' + copts.title + ': ' + rowData[fields[i]] + '

');                 }                 cc.push('
');             }             cc.push('');             return cc.join('');         }     });

Create the DataGrid

Now we use the view to create the datagrid.



    

        

            

                

                

                

                

                

            

        

    
Item IDList PriceUnit CostAttributeStatus
    


    $('#tt').datagrid({

        view: cardview

    });

Note that we set the view property, and its value is our card view.

Download the jQuery EasyUI example

jeasyui-datagrid-datagrid16.zip