1

かんばんボードのストーリーから欠陥を引き出すのに問題がある。カスタム ボードの機能の 1 つは、ストーリーに関連する欠陥をカード内に一覧表示することです。

これは 2.0p2 で動作していましたが、コードを 2.0rc1 に移植している間、欠陥配列を取り戻すことができないようです。

私はこれを次のように呼んでいました:

var defectArray = this.card.getRecord().get("Defects");

次に、典型的な for ループでそれらを繰り返します。

for (var i = 0; i < defectArray.length; i++) {
  var defect = defectArray[i];
  ...
}

以前の API は .get("Defects) でオブジェクト配列を返していましたが、現在は返していません。

私は何かが欠けていると確信しています。

4

2 に答える 2

1

次のような欠陥が返される場合があります。

var defects = story.getCollection('Defects');

2.0rc1 を使用し、ユーザー ストーリーの欠陥コレクションにアクセスする完全なコードを次に示します。コードではグリッドを作成しますが、コレクションにアクセスする部分が役立つことを願っています。

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

launch: function() {
    Ext.create('Rally.data.WsapiDataStore', {
        model: 'UserStory',
        fetch: ['FormattedID','Name','Defects'],
        pageSize: 100,
        autoLoad: true,
        listeners: {
            load: this._onDataLoaded,
            scope: this
        }
    });
},

_createGrid: function(stories) {
     this.add({
        xtype: 'rallygrid',
        store: Ext.create('Rally.data.custom.Store', {
            data: stories,
            pageSize: 100
        }),

        columnCfgs: [
            {
               text: 'Formatted ID', dataIndex: 'FormattedID'
            },
            {
                text: 'Name', dataIndex: 'Name'
            },
            {
                text: 'Defect Count', dataIndex: 'DefectCount'
            },
            {
                text: 'Defects', dataIndex: 'Defects', flex: 1, emptyCellText: 'zero',
                renderer: function(value) {
                    if (value) {
                        return value.join(',');
                    }
                }
            }
        ]

    });
},
_onDataLoaded: function(store, data){
            var stories = [];
            var pendingDefects = data.length;

            Ext.Array.each(data, function(story) {
                        var s  = {
                            FormattedID: story.get('FormattedID'),
                            Name: story.get('Name'),
                            DefectCount: story.get('Defects').Count,
                            Defects: []
                        };

                        var defects = story.getCollection('Defects');
                        defects.load({
                            fetch: ['FormattedID'],
                            callback: function(records, operation, success){
                                Ext.Array.each(records, function(defect){
                                    s.Defects.push(defect.get('FormattedID'));    
                                }, this);

                                --pendingDefects;
                                if (pendingDefects === 0) {
                                    this._createGrid(stories);
                                }
                            },
                            scope: this
                        });
                        stories.push(s);
            }, this);
}             

});

于 2013-06-28T14:54:57.883 に答える