2

2.0rc1 でユーザーストーリーとそのすべての会話投稿を取得する方法

私は試した

model:'HierarchicalRequirement',
fetch:[Discussion]

しかし、これは会話の投稿を返しません

4

1 に答える 1

1

ConvesationPosts を出力する完全なコード例を次に示します。1 つは HierarchicalRequirement オブジェクト用、もう 1 つは ConversationPost オブジェクト用の を 2 つ作成しましRally.data.WsapiDataStoreた。これは、現在 WsapiDataStore が複数のモデルを持つことができないためです。Rally.data.custom.Store

Ext.define('CustomApp', {
    extend: 'Rally.app.TimeboxScopedApp',
    componentCls: 'app',
    scopeType: 'iteration',
    comboboxConfig: {
        fieldLabel: 'Select an Iteration:',
        labelWidth: 100,
        width: 300
    },

    addContent: function() {
        this._makeStore();
    },

    _makeStore: function(){
         Ext.create('Rally.data.WsapiDataStore', {
            model: 'HierarchicalRequirement',
            fetch: ['FormattedID','Name'],
            pageSize: 100,
            autoLoad: true,
            filters: [this.getContext().getTimeboxScope().getQueryFilter()],
            listeners: {
                load: this._onConversationPostsLoaded,
                scope: this
            }
        }); 
    },

    onScopeChange: function() {
        this._makeStore();
    },

    _onConversationPostsLoaded: function(store, data){
        this.stories = data;
        Ext.create('Rally.data.WsapiDataStore', {
            model: 'ConversationPost',
            fetch: ['Text', 'Artifact'],  
            pageSize: 100,
            autoLoad: true,
            listeners: {
                load: this._onAllDataLoaded,
                scope: this
            }
        }); 
    },
    _onAllDataLoaded: function(store, data){
        var stories = [];
        var text;
        that = this;
        if (data.length ===0) {
            this._createGrid();  
        }
        Ext.Array.each(this.stories, function(story) {
            var posts = [];
            var ref = story.get('_ref');
            Ext.Array.each(data, function(post){
                if (ref === post.get("Artifact")._ref) {
                    text = post.get("Text");
                    posts.push(text);
                }
            });
            var s  = {
                FormattedID: story.get('FormattedID'),
                _ref: story.get("_ref"),  
                Name: story.get('Name'),
                Discussions: posts
            };

            stories.push(s);
            that._createGrid(stories);
        });

     },
     _createGrid: function(stories) {
        var myStore = Ext.create('Rally.data.custom.Store', {
                data: stories,
                pageSize: 100,  
            });
        if (!this.grid) {
            this.grid = this.add({
                xtype: 'rallygrid',
                itemId: 'mygrid',
                store: myStore,
                columnCfgs: [
                    {
                        text: 'Formatted ID', dataIndex: 'FormattedID', xtype: 'templatecolumn',
                        tpl: Ext.create('Rally.ui.renderer.template.FormattedIDTemplate')
                    },
                    {
                        text: 'Name', dataIndex: 'Name'
                    },
                    {
                        text: 'Discussions', dataIndex: 'Discussions', flex: 2
                    }
                ]
            }); 
        } else {
            this.grid.reconfigure(myStore);
        }
    }
});

このスクリーンショットでは、最初のストーリーには 2 つの投稿があり、2 番目のストーリーには 1 つの投稿があります。

ここに画像の説明を入力

于 2013-09-11T15:01:46.877 に答える