如何使用没有子节点的关联用户故事构建PortfolioItem / Features网格?

时间:2013-07-12 17:50:08

标签: sdk rally

我想在没有儿童故事的投资组合项目下的用户故事的我的仪表板上创建自定义网格。

1 个答案:

答案 0 :(得分:0)

我的仪表板上带有对象的自定义网格:PortfolioIetm功能和查询UserStories.DirectChildrenCount = 0 它会产生这个错误:

Could not parse: Attribute "UserStories" on type PortfolioItems is not allowed in query expressions.

这是一个自定义App SDK 2应用程序,它构建一个功能网格,其中包含DirectChildrenCount = 0的用户故事。它访问每个功能上的故事集合

var stories = feature.getCollection('UserStories');

但仅使用没有子项的故事填充网格。以下是可以粘贴到自定义标签中的完整App.html代码:

    <!DOCTYPE html>
<html>
<head>
    <title>GridExample</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/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;
                //debugger;
                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){
                                        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);
    }             
});


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

        });
    </script>




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

    </style>

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