您的位置:首页 > 产品设计 > UI/UE

EasyUI DataGrid 添加排序

2016-09-27 10:25 309 查看
这个事例演示了如何在点击列头的时候排序



DataGrid中全部的列可以通过点击列头被排序。你可以定义可以被排序的列。默认的,列不能被排序除非你设置sortable属性为TRUE,下面是例子:
标记

<table id="tt"></table>

jQuery

$('#tt').datagrid({

title:'Sortable Column',

width:550,

height:250,

url:'/demo4/data/getItems',

columns:[[

{field:'itemid',title:'Item ID',width:80,sortable:true},

{field:'productid',title:'Product ID',width:80,sortable:true},

{field:'listprice',title:'List Price',width:80,align:'right',sortable:true},

{field:'unitcost',title:'Unit Cost',width:80,align:'right',sortable:true},

{field:'attr1',title:'Attribute',width:100},

{field:'status',title:'Status',width:60}

]],

pagination:true,

sortName:'itemid',

sortOrder:'asc'

});

我们定义一些可排序的列,包括itemid,productid,listprice,unitcost等。attr1列和status列不能被排序。我们设置默认排序列:itemid,按asc(升序)排序。
当排序时, DataGrid发送两个参数到服务器:
· sort: 排序列字段名
· order: 排序次序: 'asc' 或 'desc', 默认为'asc'.
我们使用etmvc framework 写后台服务器代码,首先定义数据模型
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: