2014-05-13 1 views

답변

0

다음은 기능 아래에 스토리가 중첩되어 있고 접을 수있는 사용자 스토리의 그리드 예입니다. 배포 html은 this github repo입니다.

Ext.define('CustomApp', { 
    extend: 'Rally.app.App', 
    componentCls: 'app', 
    launch: function() { 
     var today = new Date().toISOString(); 
     Ext.create('Rally.data.wsapi.Store', { 
       model: 'UserStory', 
       fetch: ['ObjectID', 'FormattedID', 'Name', 'ScheduleState', 'Feature'], 
       autoLoad: true, 
       filters: [ 
        { 
         property: 'Iteration.StartDate', 
         operator: '<=', 
         value: today 
        }, 
        { 
         property: 'Iteration.EndDate', 
         operator: '>=', 
         value: today 
        }, 
        { 
         property: 'Feature', 
         operator: '!=', 
         value: null 
        } 
       ], 
       listeners: { 
        load: this._onDataLoaded, 
        scope: this 
       } 
       }); 
    }, 
    _onDataLoaded: function(store, records){ 
     var that = this; 
     var promises = []; 
     _.each(records, function(story) { 
      promises.push(that._getFeature(story, that)); 
     }); 

     Deft.Promise.all(promises).then({ 
      success: function(results) { 
       that._stories = results; 
       that._makeGrid(); 
      } 
     }); 
    }, 

    _getFeature: function(story, scope) { 
     var deferred = Ext.create('Deft.Deferred'); 
     var that = scope; 
      var featureOid = story.get('Feature').ObjectID; 
      Rally.data.ModelFactory.getModel({ 
      type: 'PortfolioItem/Feature', 
      scope: this, 
      success: function(model, operation) { 
       fetch: ['State'], 
       model.load(featureOid, { 
        scope: this, 
        success: function(record, operation) { 
         var featureState = record.get('State')._refObjectName; 
         var storyRef = story.get('_ref'); 
         var storyOid = story.get('ObjectID'); 
         var storyFid = story.get('FormattedID'); 
         var storyName = story.get('Name'); 
         var storyState = story.get('ScheduleState'); 
         var feature = story.get('Feature'); 

         result = { 
            "_ref"   : storyRef, 
            "ObjectID"  : storyOid, 
            "FormattedID" : storyFid, 
            "Name"   : storyName, 
            "ScheduleState" : storyState, 
            "Feature"  : feature, 
            "FeatureState" : featureState, 
            "FeatureID"  : featureOid 
           }; 
         deferred.resolve(result);  
        } 
       }); 
      } 
     }); 
     return deferred; 
    }, 

    _makeGrid: function() { 
     var that = this; 

     if (that._grid) { 
      that._grid.destroy(); 
     } 

     var gridStore = Ext.create('Rally.data.custom.Store', { 
      data: that._stories, 
      groupField: 'FeatureID', 
      pageSize: 1000, 
     }); 

     that._grid = Ext.create('Rally.ui.grid.Grid', { 
      itemId: 'storyGrid', 
      store: gridStore, 
      features: [{ftype:'grouping'}], 
      columnCfgs: [ 
       { 
        text: 'Formatted ID', dataIndex: 'FormattedID', xtype: 'templatecolumn', 
        tpl: Ext.create('Rally.ui.renderer.template.FormattedIDTemplate') 
       }, 

       { 
        text: 'Name', dataIndex: 'Name', 
       }, 
       { 
        text: 'ScheduleState', dataIndex: 'ScheduleState', 
       }, 
       { 
        text: 'Feature', dataIndex: 'Feature', 
        renderer: function(val, meta, record) { 
         return '<a href="https://rally1.rallydev.com/#/detail/portfolioitem/feature/' + record.get('Feature').ObjectID + '" target="_blank">' + record.get('Feature').FormattedID + '</a>'; 
        } 
       }, 
       { 
        text: 'Feature State', dataIndex: 'FeatureState', 
       } 
      ] 
     }); 

     that.add(that._grid); 
     that._grid.reconfigure(gridStore); 
    } 
}); 
+0

감사합니다. nickm에게 감사드립니다. 저는 여전히이 솔루션이 제 질문에 적합한 지 확인하려고합니다. 위의 코드를 기반으로 한 다른 질문을하고 싶습니다.하지만 별도의 질문으로 질문 할 것입니다. – TreverW