控制Kendo UI网格中的组排序 [英] Controlling Group order in a Kendo UI Grid

查看:255
本文介绍了控制Kendo UI网格中的组排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法来控制Kendo UI网格中的分组顺序。有一个小组我想在所有其他小组之前去,但看起来Kendo UI网格按字母顺序排列小组。



感谢
Leo

解决方案

目前没有办法对组的字段以外的其他分组进行排序。有一种方法可以像Telerik那样在非Kendo网格中进行排序,这是我现在对它们最大的特性要求。因此,我们现在坚持使用黑客。



对我而言,一种破解是将排序字段和显示字段组合到隐藏排序字段的新字符串列中隐藏范围内的部分。这是在数据源端完成的(对于我来说,在SQL中)。即使排序字段是数字,新列也被排序为字符串,因此在某些情况下您必须适当填充。

例如,如果我的数据是:

$ $ p $

$ Name $''Alice',
'Rank' :10,
'RankName':'< span class =myHiddenClass> 10< / span> Alice',
...(其他字段)
},
{
'Name':'Bob',
'Rank':9,
'RankName':'< span class =myHiddenClass> 09< / span& ,
...(其他字段)
},
{
'姓名':'Eve',
'等级':11,
' RankName':'< span class =myHiddenClass> 11< / span> Eve',
...(other fields)
}
...(Multiple Alice / Bob / Eve记录)
]

然后我可以按RankName字段进行分组而不是名称领域。它将在组标题中显示名称字段,但按Rank字段排序。在这种情况下,即使爱丽丝首次按字母顺序排列,鲍勃也会成为第一组。这与您提到的空白填充类似。


Is there a way to control the order of the grouping in a Kendo UI grid. There is a group I would like to go before all other groups, but it seems Kendo UI grid sorts the groups alphabetically. I know that adding a space to the grouping name works but that's seems very hackish.

Thanks Leo

解决方案

There is currently no way to sort a grouping on something other than the group's field. Having a way to sort groups like Telerik does in their non-Kendo grids is my biggest feature request for them right now. So we are stuck using hacks for now.

One hack that works for me is to combine the sorting field and the display field into a new string column that hides the sorting field portion inside a hidden span. This is done on the data source side (for me, in SQL). The new column is then sorted as a string even if the sorting field was a number, so you have to pad appropriately in some cases.

For example, if my data was:

[ 
    { 
      'Name': 'Alice', 
      'Rank': 10, 
      'RankName': '<span class="myHiddenClass">10</span>Alice', 
      ... (other fields)
    },  
    { 
      'Name': 'Bob', 
      'Rank': 9, 
      'RankName': '<span class="myHiddenClass">09</span>Bob', 
      ... (other fields)
    },  
    { 
      'Name': 'Eve', 
      'Rank': 11, 
      'RankName': '<span class="myHiddenClass">11</span>Eve', 
      ... (other fields)
    } 
    ... (Multiple Alice / Bob / Eve records)
]

Then I can group by the RankName field instead of the Name field. It will display the Name field in the group header but be sorted by the Rank field. In this case, Bob will show up as the first group even though Alice was first alphabetically. This works similarly to the space padding you mentioned.

这篇关于控制Kendo UI网格中的组排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆