2017-04-25 76 views
1

您好我想必須包含2個過濾器首先要篩選基於包含「自郵」字名的關鍵字數據的功能,下一個是基於在迭代框中。我試着做,但網格顯示沒有數據我使用的代碼:排序和過濾數據

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

launch: function() { 

    var filters = []; 
    var timeboxScope = this.getContext().getTimeboxScope(); 

    if(timeboxScope) { 
     filters.push(timeboxScope.getQueryFilter()); 
    } 

    this.getFilteredStoryModel(filters);    
}, 

onTimeboxScopeChange: function(newTimeboxScope) {    
    var newFilters = []; 
    var updatedTimeboxScope = this.getContext().getTimeboxScope(); 
    if (this.grid) { 
     this.grid.destroy(); 
    }     
    if (updatedTimeboxScope) { 
     newFilters.push(newTimeboxScope.getQueryFilter()); 
    } 
    this.getFilteredStoryModel(newFilters); 
}, 
getFilteredStoryModel:function(queryFilters){ 

Ext.create('Rally.data.wsapi.Store', { 
fetch: ['FormattedID','Name','Owner','ScheduleState'], 
model:"User Story", 
      filters: queryFilters, 
      autoLoad:true, 
      listeners:{ 
       load:function(myStore,myData,success){ 
        console.log("got data:",myStore,myData,success); 
        //the data is got and store in myStore if success. and the _loadTagSummary is called with the myStore pass into it 
        this.displaydata(myStore); 
       }, 
       scope:this 
      }, 
    }); 
}, 
displaydata:function(mystorystore){ 
     this.grid = this.add({ 
          xtype: 'rallygrid', 
          model: mystorystore, 
          columnCfgs: [ 
           'FormattedID', 
           'Name', 
           'Owner' 
          ], 
          storeConfig: { 
           filters: [ 
            { 
             property: 'Name', 
             operator: '=', 
             value: 'From Mail' 
            } 
           ] 
          } 
         }); 

} 

});

感謝您的幫助

回答

0

你不是超遠摘我認爲你得到周圍試圖指定絆倒在onTimeboxScopeChange(不調用父類的方法),也有一些怪事個微妙的問題網格上的商店和storeConfig。

這就是我想出了:

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

    layout: 'fit', //take up all available space 

    launch: function() { 
     this._addGrid();    
    }, 

    onTimeboxScopeChange: function(newTimeboxScope) { 
     this.callParent(arguments); //super important, or timebox scope in context doesn't ever get updated! 

     this._refreshGrid(); 
    }, 

    _addGrid: function() { 
     this.add({ 
      xtype: 'rallygrid', 
      model: 'User Story', 
      columnCfgs: [ 
       'FormattedID', 
       'Name', 
       'Owner' 
      ], 
      storeConfig: { 
       filters: this._getFilters() 
      } 
     }); 
    }, 

    _getFilters: function() { 
     var filters = [ 
      { 
       property: 'Name', 
       operator: '=', 
       value: 'From Mail' 
      } 
     ]; 

     var timeboxScope = this.getContext().getTimeboxScope();     
     if (timeboxScope) { 
      filters.push(timeboxScope.getQueryFilter()); 
     } 

     return filters; 
    }, 

    _refreshGrid: function() { 
     var grid = this.down('rallygrid'), 
      store = grid.getStore(); 

     store.clearFilter(true); 
     store.filter(this._getFilters()); 
    } 
}); 

我用在文檔的幾個不同的例子,以幫助這一點:

+0

是否可以根據關鍵字進行過濾「從郵件中」的名字? – Jonathan

+0

當然,這是什麼_getFilters功能正在做什麼。它包含Name = From Mail過濾器,然後包含一個時間框過濾器(如果可用)。你可以嘗試更改爲包含以及​​而非=接線員名精確匹配的... –

+0

是運營商,我應該把什麼?抱歉,很新的反彈 – Jonathan