$("#id").datagrid({
remoteSort : false,
idField : 'uid',
columns : [ [ {
field : '*********',
title : '*********',
sortable:true,
width : 150,
sorter : function(a, b) {
a = a.split('/');
b = b.split('/');
if (eval(a[2]) == eval(b[2])) {
if (eval(a[0]) == eval(b[0])) {
return (eval(a[1]) > eval(b[1]) ? 1 : -1);
} else {
return (eval(a[0]) > eval(b[0]) ? 1 : -1);
}
} else {
return (eval(a[2]) > eval(b[2]) ? 1 : -1);
}
}
}, {
field : '**********',
title : '*********',
sortable:true,
width : 150,
sorter:function(a,b){
a = a.split('/');
b = b.split('/');
if (eval(a[2]) == eval(b[2])) {
if (eval(a[0]) == eval(b[0])) {
return (eval(a[1]) > eval(b[1]) ? 1 : -1);
} else {
return (eval(a[0]) > eval(b[0]) ? 1 : -1);
}
} else {
return (eval(a[2]) > eval(b[2]) ? 1 : -1);
}
}
}, {
field : 'uid',
title : 'Defalut',
width : 50,
hidden : true
} ] ],
});
remoteSort : false,
idField : 'uid',
columns : [ [ {
field : '*********',
title : '*********',
sortable:true,
width : 150,
sorter : function(a, b) {
a = a.split('/');
b = b.split('/');
if (eval(a[2]) == eval(b[2])) {
if (eval(a[0]) == eval(b[0])) {
return (eval(a[1]) > eval(b[1]) ? 1 : -1);
} else {
return (eval(a[0]) > eval(b[0]) ? 1 : -1);
}
} else {
return (eval(a[2]) > eval(b[2]) ? 1 : -1);
}
}
}, {
field : '**********',
title : '*********',
sortable:true,
width : 150,
sorter:function(a,b){
a = a.split('/');
b = b.split('/');
if (eval(a[2]) == eval(b[2])) {
if (eval(a[0]) == eval(b[0])) {
return (eval(a[1]) > eval(b[1]) ? 1 : -1);
} else {
return (eval(a[0]) > eval(b[0]) ? 1 : -1);
}
} else {
return (eval(a[2]) > eval(b[2]) ? 1 : -1);
}
}
}, {
field : 'uid',
title : 'Defalut',
width : 50,
hidden : true
} ] ],
});
本文介绍如何使用EasyUI库中的数据表格(datagrid)组件,并自定义日期格式的排序方式。通过JavaScript实现了一个复杂的排序函数,该函数能够根据年/月/日的顺序进行智能排序。
194

被折叠的 条评论
为什么被折叠?



