Closed vision4fun closed 6 years ago
datatable初始化 sort 参数在 load 更新是会变成相反的
cols: [ { text: '用户名', flex: false, colClass: 'text-center' ,sort:false}, { text: '姓名', flex: false, colClass: 'text-center',sort:false }, { text: '部门', flex: false, colClass: 'text-center',sort:'up' }, { text: '操作', flex: false, colClass: 'text-center' ,sort:false} ] $('.user').datatable('load',function(data){console.log(data); return data;}) cols : Array(4) 0 : {text: "用户名", flex: false, colClass: "text-center", sort: false} 1 : {text: "姓名", flex: false, colClass: "text-center", sort: false} 2 : {text: "部门", flex: false, colClass: "text-center", sort: "down"} 3 : {text: "操作", flex: false, colClass: "text-center", sort: false} length : 4
cols: [ { text: '用户名', flex: false, colClass: 'text-center' ,sort:false}, { text: '姓名', flex: false, colClass: 'text-center',sort:false }, { text: '部门', flex: false, colClass: 'text-center',sort:'up' }, { text: '操作', flex: false, colClass: 'text-center' ,sort:false} ] $('.user').datatable('load',function(data){console.log(data); return data;})
cols : Array(4) 0 : {text: "用户名", flex: false, colClass: "text-center", sort: false} 1 : {text: "姓名", flex: false, colClass: "text-center", sort: false} 2 : {text: "部门", flex: false, colClass: "text-center", sort: "down"} 3 : {text: "操作", flex: false, colClass: "text-center", sort: false} length : 4
就初始化的时候写down实际是up,反之也是。
已确定这是一个bug,你可以将 storage 选项设置为 false 来禁用自动应用排序规则。
storage
false
临时的解决方案: 初始化的时候在 data 对象内增加一个 keepSort:true 的值
datatable初始化 sort 参数在 load 更新是会变成相反的