PDA

View Full Version : Paging info not updating after using local filtering on grid panel



jas1
3 Oct 2011, 11:06 PM
var myPageSize =20;
var userStore = Ext.create('Ext.data.Store', {
id:'userStore',
fields:['userName','isActive','isSuperAdmin','userEmail','passwordResetAt','createdAt','updatedAt'] ,
autoLoad:{start: 0, limit: myPageSize},
pageSize: myPageSize,
proxy: {
type: 'ajax',
url: 'user.do?action=doGetUsers',
reader: {
type: 'json',
root: 'users',
totalProperty:'total'
}
}
});
Ext.define('UserGrid', {
extend: 'Ext.grid.Panel',
alias:'widget.userGrid',
autoScroll:false,
store: userStore,
initComponent: function() {
var gridWidth = screenWidth-210; //200 is the width of the west region
var me = this;
me.columns = [{
xtype: 'gridcolumn',
dataIndex: 'userName',
text: 'Username',
width: gridWidth * 0.24
},{
xtype: 'gridcolumn',
dataIndex: 'userEmail',
text: 'Email ID',
width: gridWidth * 0.25
},{
xtype: 'gridcolumn',
dataIndex: 'isActive',
text: 'Active',
width: gridWidth * 0.075
},{
xtype: 'gridcolumn',
dataIndex: 'isSuperAdmin',
text: 'Super Admin',
width: gridWidth * 0.075
},{
xtype:'gridcolumn',
dataIndex:'passwordResetAt',
text:'Password Reset At',
width: gridWidth * 0.12
},{
xtype: 'gridcolumn',
dataIndex: 'createdAt',
text: 'Created Date',
width: gridWidth * 0.12
},{
xtype: 'gridcolumn',
dataIndex: 'updatedAt',
text: 'Updated Date',
width: gridWidth * 0.12
}];
me.columnLines=true;
me.viewConfig = {
forceFit: true
};

me.dockedItems = [{
xtype: 'pagingtoolbar',
id:'pagingPanel',
height: 30,
dock: 'top',
store: userStore,
width: gridWidth,
displayInfo: true,
displayMsg: 'Displaying Users {0} - {1} of {2}',
emptyMsg: "No Users to display",
items: [{
xtype: 'splitbutton',
id:'userSearchButton',
text: 'Search',
menu: [
{
xtype:'radio',
name:'searchUser',
id:'byusername',
boxLabel:'Username',
listeners:{
change:function(){
Ext.getCmp('searchUserField').setValue('');
if(Ext.getCmp('byusername').getValue()){
Ext.getCmp('userSearchButton').setText('Search By Username');
}
userStore.clearFilter();

}
}
},
{
xtype:'radio',
id:'byemail',
name:'searchUser',
boxLabel:'Email',
listeners:{
change:function(){
Ext.getCmp('searchUserField').setValue('');
if(Ext.getCmp('byemail').getValue()){
Ext.getCmp('userSearchButton').setText('Search By Email');
}
userStore.clearFilter();
}
}
}
]

},{
xtype:'textfield',
id:'searchUserField',
enableKeyEvents :true,
listeners:{
keyup:function(){
var searchString = this.getValue();
var filterString =null;
if(Ext.getCmp('byusername').getValue()){
filterString ='userName' ;
}
else if(Ext.getCmp('byemail').getValue()){
filterString ='userEmail' ;
}
if(filterString!=null && searchString!=''){
userStore.clearFilter();
userStore.filter(filterString,searchString,false,false);
}

else if(filterString==null){
Ext.Msg.alert('Warning','Please select one filter');
Ext.getCmp('searchUserField').setValue('');
}
else if(filterString||searchString.trim()===''){
userStore.clearFilter();
}




}
}
}
]

}

];
me.callParent(arguments);
}
});

This is my piece of code.searching is working fine but paging info is not updating .if i have searched for particular user intial .it does not show the exact page number andcount.i am doing filtering on client side.Please reply asap.