2016-08-23 5 views
1

こんにちは私は割り当てられたマイルストーンでUS/Defectsをグループ化しようとしています。誰かがこれを達成する方法を知っていますか? 所有者またはプロジェクト別にグループ化できますが、マイルストーンごとにグループ化する問題があります。グループRallygrid by Milestones

this.add({ 
 
         xtype: 'rallygrid', 
 
         columnCfgs: [ 
 
          'FormattedID', 
 
          'Name', 
 
          'State', 
 
          'Owner', 
 
          'Milestones' 
 
         ], 
 
         context: this.getContext(), 
 
         features: [{ 
 
          ftype: 'groupingsummary', 
 
          groupHeaderTpl: '{name} ({rows.length})' 
 
         }], 
 
         storeConfig: { 
 
          models: ['User Story', 'Defect'], 
 
          groupField: 'Milestones', 
 
          groupDir: 'ASC', 
 
         /* filters : [ 
 
           { 
 
            property : 'State', 
 
            operator : '!=', 
 
            value : 'Closed' 
 
           } 
 
          ],*/ 
 
          fetch: ['Milestones'], 
 
          getGroupString: function(record) { 
 
           var Milestones = record.get('Milestones'); 
 
           return (Milestones && Milestones._refObjectName) || 'No Milestones'; 
 
          } 
 
         } 
 
        });

ありがとう!

答えて

1

これはトリッキーなものでした。これは私が思いついたものです。

this.add({ 
    xtype: 'rallygrid', 
    columnCfgs: [ 
     'FormattedID', 
     'Name', 
     'State', 
     'Owner', 
     'Milestones' 
    ], 
    context: this.getContext(), 
    features: [{ 
     ftype: 'groupingsummary', 
     groupHeaderTpl: '{name} ({rows.length})' 
    }], 
    storeConfig: { 
     model: 'userstory', 
     groupField: 'Milestones', 
     listeners: { 
      beforeload: function(store) { 
       //remove the Milestones sorter, since Milestones 
       //is not a sortable field 
       var sorter = store.sorters.first(); 
       if (sorter && sorter.property === store.groupField) { 
        store.sorters.remove(sorter); 
       } 
      } 
     }, 
     getGroupString: function(record) { 
      var milestones = record.get('Milestones'); 

      //grab the Name field from each object in the _tagsNameArray 
      return _.pluck(milestones._tagsNameArray, 'Name').join(',') || 'None'; 
     } 
    } 
}); 

コードとの主な違いは2つあります。最初のものは、storeConfigのbeforeloadハンドラです。ストアのデフォルトの振る舞いは、sorters配列にgroupFieldを付加することです。これは通常我々が望むものですが、この場合MilestoneはWSAPIのソート可能なフィールドではないため、要求は失敗します。だから、そのソーターを取り除くだけです。

2番目の変更はgetGroupString関数にあります。マイルストーンはコレクションなので、OwnerやParentなどのオブジェクトグループフィールドの場合と同じように、_refObjectNameを直接使用することはできません。

希望に役立ちます!

+0

大変助かりました! – arf