你可能会得到这样的缺陷:
var defects = story.getCollection('Defects');
这是使用 2.0rc1 并访问用户故事中的缺陷集合的完整代码。在代码中,我构建了一个网格,但访问集合的部分有望有所帮助。
Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',
launch: function() {
Ext.create('Rally.data.WsapiDataStore', {
model: 'UserStory',
fetch: ['FormattedID','Name','Defects'],
pageSize: 100,
autoLoad: true,
listeners: {
load: this._onDataLoaded,
scope: this
}
});
},
_createGrid: function(stories) {
this.add({
xtype: 'rallygrid',
store: Ext.create('Rally.data.custom.Store', {
data: stories,
pageSize: 100
}),
columnCfgs: [
{
text: 'Formatted ID', dataIndex: 'FormattedID'
},
{
text: 'Name', dataIndex: 'Name'
},
{
text: 'Defect Count', dataIndex: 'DefectCount'
},
{
text: 'Defects', dataIndex: 'Defects', flex: 1, emptyCellText: 'zero',
renderer: function(value) {
if (value) {
return value.join(',');
}
}
}
]
});
},
_onDataLoaded: function(store, data){
var stories = [];
var pendingDefects = data.length;
Ext.Array.each(data, function(story) {
var s = {
FormattedID: story.get('FormattedID'),
Name: story.get('Name'),
DefectCount: story.get('Defects').Count,
Defects: []
};
var defects = story.getCollection('Defects');
defects.load({
fetch: ['FormattedID'],
callback: function(records, operation, success){
Ext.Array.each(records, function(defect){
s.Defects.push(defect.get('FormattedID'));
}, this);
--pendingDefects;
if (pendingDefects === 0) {
this._createGrid(stories);
}
},
scope: this
});
stories.push(s);
}, this);
}
});