0

我正在尝试制作一个显示两个功能的网格 - (汇总及其子项)。

当我将网格模型设置为“PortfolioItem/Feature”时,单个第一个查询有效,但是一旦我将模型更改为“PortfolioItem”,网格就不会显示任何数据 - 并且肯定会将 OR 添加到过滤器无济于事。

var filter = Ext.create('Rally.data.QueryFilter', {
    property: 'Parent.ObjectID',
    operator: '=',
    value: id
});

filter = filter.or({
    property: 'ObjectID',
    operator: '=',
    value: id
});

我会以错误的方式解决这个问题吗?我知道在使用 PortfolioItem 模型之前我已经制作了一个特征和汇总网格,但我是根据开始和结束日期进行过滤的。

4

1 回答 1

0

这是一个简单的网格,显示所有投资组合项目类型、主题、倡议、功能,其中

model: 'PortfolioItem'

如果我只获取一个特定于一种 PI 类型的属性,例如 PortfolioItem/Feature 上的 UserStories:

fetch: ['FormattedID','Name']

并在代码中有这样的东西:

 StoryCount: feature.get('UserStories').Count

当网格不显示任何数据时,我将看到与您报告的结果相同的结果。

<!DOCTYPE html>
<html>
<head>
    <title>PIGridExample</title>

    <script type="text/javascript" src="/apps/2.0rc1/sdk.js"></script>

<script type="text/javascript">
Rally.onReady(function () {
Ext.define('CustomApp', {
    extend: 'Rally.app.App',
    componentCls: 'app',

    launch: function() {
        Ext.create('Rally.data.WsapiDataStore', {
            model: 'PortfolioItem',
            fetch: ['FormattedID','Name'],
            pageSize: 100,
            autoLoad: true,
            listeners: {
                load: this._onDataLoaded,
                scope: this
            }
        });
    },
     _onDataLoaded: function(store, data) {
                    var records = [];
                    Ext.Array.each(data, function(record) {
                        records.push({
                            Name: record.get('Name'),
                            FormattedID: record.get('FormattedID'),
                        });
                    });

                    this.add({
                        xtype: 'rallygrid',
                        store: Ext.create('Rally.data.custom.Store', {
                            data: records
                        }),
                        columnCfgs: [
                            {
                                text: 'Name', dataIndex: 'Name', flex: 1
                            },
                            {
                                text: 'FormattedID', dataIndex: 'FormattedID'
                            }
                        ]
                    });
                }


});
            Rally.launchApp('CustomApp', {
                name:"PIGridExample"
                //parentRepos:""
            });

        });
    </script>

    <style type="text/css">
.app {
     /* Add app styles here */
}

    </style>

</head>
<body></body>
</html>

下面是一个具有功能网格及其用户商店的应用程序示例:

Ext.define('CustomApp', {
    extend: 'Rally.app.App',
    componentCls: 'app',

    launch: function() {
        Ext.create('Rally.data.WsapiDataStore', {
            model: 'PortfolioItem/Feature',
            fetch: ['FormattedID','Name','UserStories'],
            pageSize: 100,
            autoLoad: true,
            listeners: {
                load: this._onDataLoaded,
                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: '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(', ');
                    }
                }
            ]

        });
    },
    _onDataLoaded: function(store, data){
                var features = [];
                var pendingstories = data.length;
                Ext.Array.each(data, function(feature) {
                            var f  = {
                                FormattedID: feature.get('FormattedID'),
                                Name: feature.get('Name'),
                                _ref: feature.get("_ref"),
                                StoryCount: feature.get('UserStories').Count,
                                UserStories: []
                            };

                            var stories = feature.getCollection('UserStories');
                           stories.load({
                                fetch: ['FormattedID'],
                                callback: function(records, operation, success){
                                    Ext.Array.each(records, function(story){  
                                            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);
    }             
});
于 2013-07-26T20:12:45.327 回答