PDA

View Full Version : DataStore filter: How to refresh grid after filter applied?



Tumac
8 Nov 2010, 9:08 AM
I have read the API and configured a filter statement for a grid.

My goal is to load a grid with all records. In the top Toolbar, I then have buttons that when pressed show only a subset of the data in the grid. It appears my filter is applied but the grid is not refreshed, what am I missing?


Ext.ns("STS");
Ext.BLANK_IMAGE_URL = 'assets/img/tp/s.gif';
Ext.ux.Loader.load([
'STSCls/grid/DashSalesSKU.js'
]
,function() { // callback when finished loading
}
,this // scope
);

STS.DashSalesPortal = Ext.extend(Ext.Panel, {
layout : 'fit'
,border : false
,initComponent : function() {
this.items= [
this.buildPortal()
];

STS.DashSalesPortal.superclass.initComponent.call(this);

}
,buildPortal : function() {

var tbar = [
{
text : 'On Order'
//,icon : 'assets/img/icons/table_edit.png'
,scope : this
,handler : function() {
var status='On Order'
this.filterStatus(status);
}
},'-',{
text : 'In Transit'
// ,icon : 'assets/img/icons/stop.png'
,scope : this
,handler : function() {
var status='In Transit'
this.filterStatus(status);
}
},'-',{
text : 'Stock'
// ,icon : 'assets/img/icons/stop.png'
,scope : this
,handler : function() {
var status='Stock'
this.filterStatus(status);
}
},'-',{
text : 'Shipped'
// ,icon : 'assets/img/icons/stop.png'
,scope : this
,handler : function() {
var status='Shipped'
this.filterStatus(status);
}
}
];

return {
xtype : 'panel'
,itemId: 'salesSwitcher'
,layout : 'accordion'
,layoutConfig: {
activeOnTop: true
,animate: true
,style: 'background-color: #FFF'
}
,titleCollapse: true
,items : [{
xtype : 'dashsalessku'
,id : 'skuSalesGrid'
,itemId : 'skuSalesGrid'
,title : "Item Sales by Status"
,tbar : tbar
}]
};
}
,filterStatus : function(status){
switch(status) {

case(status="On Order") :
var grid = Ext.getCmp('skuSalesGrid')
grid.store.filter([
{
field : 'Status'
,value : 'On Order'
}]);
console.log(grid.store.record);

break;
case(status="In Transit") :
Ext.getCmp('skuSalesGrid').store.filter([
{
property : 'Status'
,value : 'In Transit'
}]);
;
break;
case(status="Stock") :
Ext.getCmp('skuSalesGrid').store.filter([
{
property : 'Status'
,value : 'Stock'
}]);

break;
case(status="Shipped") :
Ext.getCmp('skuSalesGrid').store.filter([
{
property : 'Status'
,value : 'Ship'
}]);

break;
}
}



}); //EOF

Ext.reg('dashsalesportal', STS.DashSalesPortal);