gpt4 book ai didi

extjs - Rally SDK 2 自定义分类器

转载 作者:行者123 更新时间:2023-12-01 07:02:47 24 4
gpt4 key购买 nike

如何对查询进行更复杂的排序,我目前有这个查询:

    var store = Ext.create('Rally.data.custom.Store',{
data: changes,
limit: 'Infinity',
pageSize: 5000,
sorters: [
{
property: 'ReleaseScope',
direction: 'ASC'
},
{
property: 'ScheduleState',
direction: 'DESC'
}
]

});

因为 ScheduleState 是水合的,所以我不能按普通数字排序,我可以使用某种匹配器定义顺序吗?

即说我想按顺序显示 [Accepted, Completed, In-Progress, Defined, Backlog]而且,如果我想进一步复杂化并首先显示带有故事点的故事,比如

All stories with a story point value != 0
Sorted by schedulestate [accepted, completed, in-progress, defined etc..]
stories with no story point value
some other sort here possibly

最佳答案

您可以传递 sorterFn 而不是属性/方向组合来实现自定义排序逻辑:

sorters: [
{
sorterFn: function(a, b) {
var scheduleStates = ['Accepted', 'Completed', 'In-Progress', 'Defined'],
aState = a.get('ScheduleState'),
aIndex = _.indexOf(scheduleStates, aState),
bState = b.get('ScheduleState'),
bIndex = _.indexOf(scheduleStates, bState);
return a - b;
}
}
]

我认为上述函数应该根据计划状态降序对它们进行排序。

关于extjs - Rally SDK 2 自定义分类器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25373702/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com