我正在尝试在集会中创建自定义html应用。在将添加该应用程序的页面中,我有一个发布过滤器。我想为用户选择的发行版创建功能列表。通过在存储中为功能部件定义过滤器,看起来我应该能够将用户选择的版本的_ref字段与功能部件的Release._ref匹配。我认为它不起作用,因为某些功能未定义发布,因此当过滤器尝试检查Release._ref时,Release为null,因此引发null引用错误。这似乎是一件非常基本的事情。正确的方法是什么?
我认为很重要的snipit代码:
console.log('_loadData');
var timeBoxScope = this.getContext().getTimeboxScope().record.data._ref; // only works in Rally for custom page with Release filter
console.log('timebox', timeBoxScope);
var myStore = Ext.create('Rally.data.wsapi.Store', {
model: 'PortfolioItem/Feature',
pageSize: 10,
autoLoad: true,
fetch: ['FormattedID', 'Name', 'Owner', 'Release', 'UserStories'],
filters: [
{
property: 'Release._ref',
operator: '=',
value: timeBoxScope
}],
listeners: {
我正在研究的全部内容:
Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',
launch: function () {
console.log('launch');
this._loadData();
},
// load rally data
_loadData: function () {
console.log('_loadData');
var timeBoxScope = this.getContext().getTimeboxScope().record.data._ref; // only works in Rally for custom page with Release filter
console.log('timebox', timeBoxScope);
var myStore = Ext.create('Rally.data.wsapi.Store', {
model: 'PortfolioItem/Feature',
pageSize: 10,
autoLoad: true,
fetch: ['FormattedID', 'Name', 'Owner', 'Release', 'UserStories'],
filters: [
{
property: 'Release._ref',
operator: '=',
value: timeBoxScope
}],
listeners: {
load: function(store, data){
var features = [];
var pendingstories = data.length;
//debugger;
Ext.Array.each(data, function(feature) {
var f = {
FormattedID: feature.get('FormattedID'),
Name: feature.get('Name'),
_ref: feature.get("_ref"),
Owner: feature.get("Owner")._refObjectName,
StoryCount: feature.get('UserStories').Count,
UserStories: []
};
console.log('feature', feature);
console.log('feature release', feature.data.Release._ref);
var stories = feature.getCollection('UserStories');
stories.load({
fetch: ['FormattedID'],
callback: function(records, operation, success){
Ext.Array.each(records, function(story){
var number = story.get('DirectChildrenCount');
if (number == 0) {
f.UserStories.push({_ref: story.get('_ref'),
FormattedID: story.get('FormattedID')
});}
}, this);
--pendingstories;
if (pendingstories === 0) {
this._createGrid(features);
}
},
scope: this
});
features.push(f);
}, this);
},
scope: this
}
});
},
_createGrid: function(features) {
this.add({
xtype: 'rallygrid',
store: Ext.create('Rally.data.custom.Store', {
data: features,
pageSize: 100
}),
columnCfgs: [
{
text: 'Formatted ID', dataIndex: 'FormattedID', xtype: 'templatecolumn',
tpl: Ext.create('Rally.ui.renderer.template.FormattedIDTemplate')
},
{
text: 'Name', dataIndex: 'Name'
},
{
text: 'Owner', dataIndex: 'Owner'
},
{
text: 'Story Count', dataIndex: 'StoryCount'
},
{
text: 'User Stories', dataIndex: 'UserStories',
renderer: function(value) {
var html = [];
Ext.Array.each(value, function(userstory){
html.push('<a href="' + Rally.nav.Manager.getDetailUrl(userstory) + '">' + userstory.FormattedID + '</a>');
});
return html.join(', ');
}
}
]
});
}
} );
答案 0 :(得分:0)
我自己找到了答案。正如我所怀疑的那样,我做错了。这是设置过滤器的方法。请参见下面的“过滤器”定义:
var timeBoxScope = this.getContext().getTimeboxScope();//.record.data._ref; // only works in Rally for custom page with Release filter
console.log('timebox', timeBoxScope);
var myStore = Ext.create('Rally.data.wsapi.Store', {
model: 'PortfolioItem/Feature',
pageSize: 10,
autoLoad: true,
fetch: ['FormattedID', 'Name', 'Owner', 'Release', 'UserStories'],
filters: timeBoxScope.getQueryFilter(),
listeners: {