通过给 columns
数据的项,设置 sortable: true
,即可对该列数据进行排序。
这个是系统的排序。
自定义排序
设置属性 sortMethod
指定一个自定义排序函数,接收三个参数 a 、 b 和 type。
{
title: "标签值",
key: "dkey",
align: "center",
sortable: true,
sortMethod:function(a,b,type) {
console.log(a,b,type); if (type == 'desc') { return parseInt(a) > parseInt(b)? -1 : 1 } else { return parseInt(a) < parseInt(b)? -1 : 1 }
}
},