我在dataSource中将数据分组为:
I have grouped data in dataSource as:
var dataSource = new kendo.data.DataSource({ transport: { read: { url: " ", } }, //and some other parameters specified // group by the "category" field group: { field: "category", aggregates: [ { field: "price", aggregate: "max" }, { field: "price", aggregate: "min" } ] } });现在,我想根据此处指定的字段以外的其他字段对组进行排序.如何做到这一点?或者如何禁用或覆盖默认的"dir"升序排序行为.
Now i want to sort the group according to field other than the field specified here. How this could be achieved? Or how can i disable or override the default sorting behavior of "dir" as ascending.
推荐答案有一种未公开的方法来指定自定义排序函数,该函数将允许您对对象公开的任何一个或多个属性进行排序.
There is an undocumented way to specify a custom sort function which will allow you to sort on any property/properties exposed by your object.
$("#grid").kendoGrid({ columns: [ { field: "someProperty", sortable: { compare: function (left, right) { // TODO: your custom logic here (just make sure you return a number) return left.someOtherProperty - right.someOtherProperty; } }, title: "I can do custom sorting!!!" ], dataSource: { .. }, // other grid properties here });如果left小于right,则compare函数应返回一个负数;如果相等,则返回0;如果left大于right,则该函数应返回一个正数.
The compare function should return a negative number if left is less than right, 0 if they are equal, and a positive number if left is greater than right.
更多推荐
KendoUI网格/数据源中的自定义排序
发布评论