2013-11-15 50 views

回答

1

您也可以尝试通过你的配置到getCollection方法来代替。我认为直接将它们传递到负载中存在一些错误。我有这样的好运气:

testSet.getCollection('TestCases', { 
    limit: Infinity, 
    autoLoad: true 
    listeners: { 
     load: function(store, records) { 
      //process testcases 
     }, 
     scope: this 
    } 
}); 
1

这是一个代码示例,它构建了包含关联测试用例的测试集网格。 TestSets由发布过滤:

Ext.define('CustomApp', { 
    extend: 'Rally.app.TimeboxScopedApp', 
    componentCls: 'app', 
    scopeType: 'release', 

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

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

    _makeStore: function(){ 
     Ext.create('Rally.data.WsapiDataStore', { 
       model: 'TestSet', 
       fetch: ['FormattedID', 'TestCases', 'TestCaseStatus'], 
       pageSize: 100, 
       autoLoad: true, 
       filters: [this.getContext().getTimeboxScope().getQueryFilter()], 
       listeners: { 
        load: this._onTestSetsLoaded, 
        scope: this 
       } 
      }); 
    }, 
    _onTestSetsLoaded: function(store, data){ 
     var testSets = []; 
     var pendingTestCases = data.length; 
     console.log(data.length); 
     if (data.length ===0) { 
      this._createTestSetGrid(testSets); 
     } 
     Ext.Array.each(data, function(testset){ 
      var ts = { 
       FormattedID: testset.get('FormattedID'), 
       _ref: testset.get('_ref'), //required to make FormattedID clickable 
       TestCaseStatus: testset.get('TestCaseStatus'), 
       TestCaseCount: testset.get('TestCases').Count, 
       TestCases: [] 
      }; 
      var testCases = testset.getCollection('TestCases'); 
      testCases.load({ 
           fetch: ['FormattedID'], 
           callback: function(records, operation, success){ 
            Ext.Array.each(records, function(testcase){ 
             ts.TestCases.push({_ref: testcase.get('_ref'), 
                 FormattedID: testcase.get('FormattedID') 
                }); 
            }, this); 
            --pendingTestCases; 
            if (pendingTestCases === 0) { 
             this._createTestSetGrid(testSets); 
            } 
           }, 
           scope: this 
          }); 
      testSets.push(ts); 
    },this); 
}, 

     _createTestSetGrid: function(testsets) { 
     var testSetStore = Ext.create('Rally.data.custom.Store', { 
       data: testsets, 
       pageSize: 100, 
      }); 
     if (!this.down('#testsetgrid')) { 
     this.grid = this.add({ 
      xtype: 'rallygrid', 
      itemId: 'testsetgrid', 
      store: testSetStore, 
      columnCfgs: [ 
       { 
        text: 'Formatted ID', dataIndex: 'FormattedID', xtype: 'templatecolumn', 
        tpl: Ext.create('Rally.ui.renderer.template.FormattedIDTemplate') 
       }, 
       { 
        text: 'Test Case Count', dataIndex: 'TestCaseCount', 
       }, 
       { 
        text: 'Test Case Status', dataIndex: 'TestCaseStatus',flex:1 
       }, 
       { 
        text: 'TestCases', dataIndex: 'TestCases',flex:1, 
        renderer: function(value) { 
         var html = []; 
         Ext.Array.each(value, function(testcase){ 
          html.push('<a href="' + Rally.nav.Manager.getDetailUrl(testcase) + '">' + testcase.FormattedID + '</a>') 
         }); 
         return html.join(', '); 
        } 
       } 
      ] 
     }); 
     }else{ 
      this.grid.reconfigure(testSetStore); 
     } 
    } 
}); 
相关问题