easyUI 自定义排序datagrid
来源:互联网 发布:税务软件下载 编辑:程序博客网 时间:2024/05/04 05:38
@author YHC
如果默认的排序行为不满足你的需求,你可以自定义datagrid排序行为.
最基础的用户可以定义一个排序函数,函数名是sorter 在列上,这个函数将接受两个值和返回值将作为如下:
valueA > valueB => return 1
valueA < valueB => return -1
自定义排序代码
<table id="tt"></table>
$('#tt').datagrid({ title:'Custom Sort', iconCls:'icon-ok', width:520, height:250, singleSelect:true, remoteSort:false, columns:[[ {field:'itemid',title:'Item ID',width:60,sortable:true}, {field:'listprice',title:'List Price',width:70,align:'right',sortable:true}, {field:'unitcost',title:'Unit Cost',width:70,align:'right',sortable:true}, {field:'attr1',title:'Attribute',width:120,sortable:true}, {field:'date',title:'Date',width:80,sortable:true,align:'center', sorter:function(a,b){ a = a.split('/'); b = b.split('/'); if (a[2] == b[2]){ if (a[0] == b[0]){ return (a[1]>b[1]?1:-1); } else { return (a[0]>b[0]?1:-1); } } else { return (a[2]>b[2]?1:-1); } } }, {field:'status',title:'Status',width:40,align:'center'} ]] }).datagrid('loadData', data);你可以从这段代码中看到,我们为date列创建了自定义的sorter ,日期的格式是 'dd/mm/yyyy' ,可以轻松的按年月日排序.
下载 EasyUI示例代码:
easyui-datagrid-demo.zip
- easyUI 自定义排序datagrid
- 【Easyui】Easyui Datagrid 排序
- EasyUI Datagrid 前端按数字排序(自定义排序)
- JQuery easyUI datagrid 排序,使用sorter自定义排序
- EasyUI Datagrid 前端按数字排序(自定义排序)
- JQuery easyUI datagrid 排序,使用sorter自定义排序
- JQuery easyUI datagrid 排序,使用sorter自定义排序
- easyui datagrid自定义操作
- easyui datagrid自定义表头
- easyui datagrid 样式自定义
- easyui datagrid排序
- EasyUI datagrid列排序
- Easyui Datagrid 排序
- easyUI自定义DataGrid分页栏
- easyui datagrid自定义操作列
- easyui datagrid自定义操作列
- easyUI自定义DataGrid分页栏
- easyui datagrid pagination 自定义分页
- 低级错误
- Redis详细完整教程-windows下的安装、测试(php+redis+mysql)
- uiwebview didFailLoadWithError -999 error code
- 一个对话框调用另一个对话框的控件值
- socket和shutdown
- easyUI 自定义排序datagrid
- 浅谈千万级PV/IP规模高性能高并发网站架构
- http详解(http://www.cnblogs.com/TankXiao/archive/2012/02/13/2342672.html)
- 字符串匹配--KMP算法
- 51ec助理 ecshop助理
- MFC之Unicode编程
- Oracle执行计划详解
- ZOJ 3529 A Game Between Alice and Bob (数论+SG博弈)
- 内核编译--make menuconfig 报错make menuconfig' requires the ncurses libraries解决方法