首页 > 解决方案 > 通过上下文时间框中的版本集使用 wsapi 存储过滤功能时遇到问题

问题描述

我正在尝试在拉力赛中创建自定义 html 应用程序。在将添加应用程序的页面中,我有一个发布过滤器。我想为用户选择的版本创建功能列表。看起来我应该能够通过在商店中为功能定义一个过滤器来将用户选择的版本的 _ref 字段与功能的 Release._ref 匹配。我认为它不起作用,因为某些功能没有定义发布,因此当过滤器尝试检查 Release._ref 时,Release 为空,因此引发空引用错误。这似乎是一件非常基本的事情。这样做的正确方法是什么?

我认为很重要的代码片段:

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(', ');
                }
            }
        ]

    });
}

});

标签: rally

解决方案


我自己找到了答案。正如我所怀疑的那样,我做错了。这是设置过滤器的方法。请参阅下面的“过滤器”定义:

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: {

推荐阅读