按里程碑分组 Rallygrid
Group Rallygrid by Milestones
您好,我正在尝试按分配给他们的里程碑对 US/Defects 进行分组。有谁知道实现这一目标的方法?
我可以按所有者或项目分组,但在按里程碑分组时遇到问题。
this.add({
xtype: 'rallygrid',
columnCfgs: [
'FormattedID',
'Name',
'State',
'Owner',
'Milestones'
],
context: this.getContext(),
features: [{
ftype: 'groupingsummary',
groupHeaderTpl: '{name} ({rows.length})'
}],
storeConfig: {
models: ['User Story', 'Defect'],
groupField: 'Milestones',
groupDir: 'ASC',
/* filters : [
{
property : 'State',
operator : '!=',
value : 'Closed'
}
],*/
fetch: ['Milestones'],
getGroupString: function(record) {
var Milestones = record.get('Milestones');
return (Milestones && Milestones._refObjectName) || 'No Milestones';
}
}
});
谢谢!
这是一个棘手的问题。这就是我想出的:
this.add({
xtype: 'rallygrid',
columnCfgs: [
'FormattedID',
'Name',
'State',
'Owner',
'Milestones'
],
context: this.getContext(),
features: [{
ftype: 'groupingsummary',
groupHeaderTpl: '{name} ({rows.length})'
}],
storeConfig: {
model: 'userstory',
groupField: 'Milestones',
listeners: {
beforeload: function(store) {
//remove the Milestones sorter, since Milestones
//is not a sortable field
var sorter = store.sorters.first();
if (sorter && sorter.property === store.groupField) {
store.sorters.remove(sorter);
}
}
},
getGroupString: function(record) {
var milestones = record.get('Milestones');
//grab the Name field from each object in the _tagsNameArray
return _.pluck(milestones._tagsNameArray, 'Name').join(',') || 'None';
}
}
});
与您的代码有两个主要区别。第一个是 storeConfig 中的 beforeload 处理程序。商店的默认行为是将 groupField 添加到 sorters 数组中。这通常是我们想要的,但在这种情况下,Milestones 不是 WSAPI 中的可排序字段,因此请求失败。所以我们只删除那个分拣机。
第二个变化是在 getGroupString 函数中。 Milestones 是一个集合,因此您不能像 Owner 或 Parent 等对象组字段那样直接使用 _refObjectName。
希望对您有所帮助!
您好,我正在尝试按分配给他们的里程碑对 US/Defects 进行分组。有谁知道实现这一目标的方法? 我可以按所有者或项目分组,但在按里程碑分组时遇到问题。
this.add({
xtype: 'rallygrid',
columnCfgs: [
'FormattedID',
'Name',
'State',
'Owner',
'Milestones'
],
context: this.getContext(),
features: [{
ftype: 'groupingsummary',
groupHeaderTpl: '{name} ({rows.length})'
}],
storeConfig: {
models: ['User Story', 'Defect'],
groupField: 'Milestones',
groupDir: 'ASC',
/* filters : [
{
property : 'State',
operator : '!=',
value : 'Closed'
}
],*/
fetch: ['Milestones'],
getGroupString: function(record) {
var Milestones = record.get('Milestones');
return (Milestones && Milestones._refObjectName) || 'No Milestones';
}
}
});
谢谢!
这是一个棘手的问题。这就是我想出的:
this.add({
xtype: 'rallygrid',
columnCfgs: [
'FormattedID',
'Name',
'State',
'Owner',
'Milestones'
],
context: this.getContext(),
features: [{
ftype: 'groupingsummary',
groupHeaderTpl: '{name} ({rows.length})'
}],
storeConfig: {
model: 'userstory',
groupField: 'Milestones',
listeners: {
beforeload: function(store) {
//remove the Milestones sorter, since Milestones
//is not a sortable field
var sorter = store.sorters.first();
if (sorter && sorter.property === store.groupField) {
store.sorters.remove(sorter);
}
}
},
getGroupString: function(record) {
var milestones = record.get('Milestones');
//grab the Name field from each object in the _tagsNameArray
return _.pluck(milestones._tagsNameArray, 'Name').join(',') || 'None';
}
}
});
与您的代码有两个主要区别。第一个是 storeConfig 中的 beforeload 处理程序。商店的默认行为是将 groupField 添加到 sorters 数组中。这通常是我们想要的,但在这种情况下,Milestones 不是 WSAPI 中的可排序字段,因此请求失败。所以我们只删除那个分拣机。
第二个变化是在 getGroupString 函数中。 Milestones 是一个集合,因此您不能像 Owner 或 Parent 等对象组字段那样直接使用 _refObjectName。
希望对您有所帮助!