jQuery EasyUI使用教程之在数据网格中自定义排序
来源:互联网 发布:软件设计师考试好考吗 编辑:程序博客网 时间:2024/05/23 18:43
<jQuery EasyUI最新试用版免费下载>
如果默认排序行为不能满足您的需求,您可以自定义数据网格的排序行为。
基本上用户可以在列上定义一个函数名为sorter的排序函数。这个函数将要接受两个值,返回值将如下:
valueA > valueB => return 1
valueA < valueB => return -1
自定义排序代码
1
<
table
id
=
"tt"
></
table
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
$(
'#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);
正如您从这个代码中看到,我们创建了一个自定义排序日期。日期格式为“DD / MM / YYYY”,可以轻松地按年月日排序。
下载该EasyUI示例:easyui-datagrid-demo.zip
有兴趣的朋友可以点击查看更多有关jQuery EasyUI的教程!
1 0
- jQuery EasyUI使用教程之在数据网格中自定义排序
- jQuery EasyUI使用教程之自定义数据网格分页
- jQuery EasyUI使用教程之在数据网格中添加一个分页
- jQuery EasyUI使用教程之在数据网格中添加搜索功能
- jQuery EasyUI使用教程之在数据网格中创建列组
- jQuery EasyUI使用教程之在数据网格中创建列组
- jQuery EasyUI使用教程之在数据网格中扩展行显示详细信息
- jQuery EasyUI使用教程之创建数据网格的自定义视图
- jQuery EasyUI使用教程之添加工具栏到数据网格
- jQuery EasyUI使用教程之动态改变数据网格列
- jQuery EasyUI使用教程之格式化数据网格列
- jQuery EasyUI使用教程之启用数据网格内联编辑
- jQuery EasyUI使用教程之扩展数据网格的编辑器
- jQuery EasyUI使用教程之合并数据网格的单元格
- jQuery EasyUI使用教程之在数据网格的页脚中显示摘要信息
- jQuery EasyUI使用教程之从数据网格中获取选中行数据
- jQuery EasyUI使用教程之在树网格中动态加载
- jQuery EasyUI使用教程之在树网格中延迟加载节点
- vi命令
- 2016.1.16 Maven使用和项目整理
- python 函数
- 获取手机存储空间大小
- 【异常】百度定位sdk Couldn't load locSDK3 from loader dalvik findLibrary returned null
- jQuery EasyUI使用教程之在数据网格中自定义排序
- windows使用git时出现:warning: LF will be replaced by CRLF
- Fragment之间的跳转,和数据的传递
- 设计模式C++实现:单例模式(Singleton)
- 2016.1.18 SlidingMenu和Viewpager的使用
- json对象与字符串的转换方法
- 爬虫 正则表达式
- eclipse 集成flex插件编译失败解决
- sprintf