2013-11-26 38 views
0

我要過濾我的店裏有Month值:如何獲得最近六個月的商店?

//On clicking the Last Six Months period button 
onLsmClick: function() { 
    var chart = Ext.widget('drawchart'); 
    var chartStore = this.getGraphDataStore(); 
    chartStore.clearFilter(true); 

    chartStore.filter([{ 
     filterFn: function (item) { 
      return (item.get('Month') >= ????? && (item.get('Month') < ?????) 
     } 
    }]); 
    chartStore.sync = true; 
    chart.redraw(); 
    chart.refresh(); 
}, 

回答

0
//Finding right month 
chartStore.filterBy(function(record){ 
     var index = chart 
     return record.getData().Month >= ???? && record.getData().Month < ????; 
}); 

//Finding last 6 records 
var count = chartStore.getCount(); 
chartStore.filterBy(function(record){ 
     var index = chartStore.find('Month', record.month, 0, false, true, true); //Get current index of record based on month 
     return index >= count - 6; 
}); 

參考此鏈接的文檔 http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.data.Store-method-filterBy

+0

謝謝,但實際上,我停留在如何讓*最後六*我店的幾個月... – salamey