2017-04-25 89 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