2013-07-17 25 views
0

我編寫了一個應用程序,該應用程序構建了由迭代過濾的用戶故事網格。它似乎工作,並沒有錯誤,但故事列表不完整。一些迭代在網格中缺少一半的故事。所有故事都在同一個項目中。我究竟做錯了什麼?如果您有關於如何改進下面的代碼的建議,請讓我知道。謝謝!AppSDK2故事迭代應用程序無法顯示迭代中的所有故事

<!DOCTYPE html> 
    <html> 
     <head> 
      <title>StoriesByIteration</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.TimeboxScopedApp', 
         componentCls: 'app', 
         scopeType: 'iteration', 
         comboboxConfig: { 
          labelWidth: 100, 
          width: 300 
         }, 

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

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

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

         _onDataLoaded: function(store, data){ 
          var stories = []; 
          Ext.Array.each(data, function(story) { 
           var s = { 
            FormattedID: story.get('FormattedID'), 
            Name: story.get('Name'), 
           }; 
           this._createGrid(stories); 
           stories.push(s); 
          }, this); 
         },    

         _createGrid: function(stories) { 
          var myStore = Ext.create('Rally.data.custom.Store', { 
           data: stories, 
           pageSize: 100, 
          }); 

          if (!this.grid) { 
           this.grid = this.add({ 
            xtype: 'rallygrid', 
            store: myStore, 
            columnCfgs: [ 
             { 
              text: 'Formatted ID', dataIndex: 'FormattedID', xtype: 'templatecolumn', 
              tpl: Ext.create('Rally.ui.renderer.template.FormattedIDTemplate') 
             }, 
             { 
              text: 'Name', dataIndex: 'Name' 
             } 
            ] 
           }); 
          } else { 
          this.grid.reconfigure(myStore); 
          } 
         } 
        }); 

        Rally.launchApp('CustomApp', { 
         name:"StoriesByIteration", 
        }); 
       }); 
      </script> 
      <style type="text/css"> 
       .app { } 
      </style> 
     </head> 
    <body></body> 
</html> 

回答

0

您需要將循環

this._createGrid(stories); 

外:

_onDataLoaded: function(store, data){ 
       var stories = []; 
       Ext.Array.each(data, function(story) { 
          var s = { 
           FormattedID: story.get('FormattedID'), 
           Name: story.get('Name'), 
          }; 
          stories.push(s); 
       }, this); 
       this._createGrid(stories); 
    },