KendoUI网格/数据源中的自定义排序

编程入门 行业动态 更新时间:2024-10-12 18:21:23
本文介绍了KendoUI网格/数据源中的自定义排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在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网格/数据源中的自定义排序

本文发布于:2023-07-09 21:25:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1088248.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:数据源   自定义   网格   KendoUI

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!