0

我想在没有子故事的投资组合项下的“我的用户故事仪表板”上创建一个自定义网格。

4

1 回答 1

0

My Dashboard 上带有 Object: PortfolioIetm Feature 的自定义网格并查询 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>
于 2013-07-12T18:00:03.537 回答