PDA

View Full Version : PagingToolbar with dynamic pagesize



ssawant
24 Jan 2011, 7:12 AM
Hello all,

Thanks in advance! :)

I am using EditorGridPanel with PagingToolbar. I have tried to implement a feature like 'dynamic pagesize'.
a custom pagesize textfield is provided in PagingToolbar, As the pagesize is modified, store reloads the data as per the new pagesize.

The above stuff is working fine. But, when next button of paging toolbar is clicked, store reloads the same data and it shows wrong params.
E.g. If pagesize = 15, it gives following results: -
First Page - Start: 0, limit: 15, displayMsg: 'page 1 of 3'.
Second Page - Start: 015, limit: 15, displayMsg: 'page 101 of 3'.
Third Page - Start: 01515, limit: 15, displayMsg: 'page 1010 of 3'

So, the pagination with dynamic pagesize is not working :s

Please help me...

Thank you.

mschwartz
24 Jan 2011, 7:16 AM
Search for PageSize plugin.

ssawant
24 Jan 2011, 7:21 AM
Okay, Thank you. :)
I will paste a piece of code here for your reference!

ssawant
24 Jan 2011, 7:28 AM
Here is a piece of code..



new Ext.PagingToolbar(
{
id: 'myPagingToolbar',
store: 'myStore',
pageSize: myPageSize,
displayInfo: true,
emptyMsg: 'Sorry, No Records Are Available At The Moment.'
})

if(Ext.getCmp('myGrid').getBottomToolbar() != null)
{
Ext.getCmp('myGrid').getBottomToolbar().bindStore(Ext.getCmp('myGrid').getStore());
Ext.getCmp('myGrid').getBottomToolbar().add('->',
{
xtype: 'textfield',
id: 'maxRowsTextField',
selectOnFocus: true,
allowBlank: true,
value: myPageSize,
width : 50,
name: 'Max Rows',
validateOnBlur: false,
validationEvent: false,
submitValue: false,
listeners:
{
change: function(maxRows, newValue, oldValue)
{
if(maxRows != null)
{
if((newValue < 10) || (newValue > 200))
{
Ext.Msg.show({
title:'Error In Pagesize!',
msg: 'Please Enter Pagesize between 0 and 200',
closable: false,
buttons: Ext.Msg.OKCANCEL,
fn: function(buttonId, text)
{
if (buttonId == 'ok')
{
newValue = 0;
}
},
icon: Ext.MessageBox.ERROR
});
}

Ext.getCmp('myGrid').getBottomToolbar().pageSize = newValue;
Ext.apply({params:{start: 0, limit: newValue}}, {
myNewParam: true
});
Ext.getCmp('myGrid').getStore().reload({params:{start: 0, limit: newValue}});
}
}
}
}
);
}


Thank you.

tryanDLS
24 Jan 2011, 7:42 AM
Please post in the correct forum and don't double post - thread mod is on.

KNS
22 Sep 2011, 2:59 PM
Could you tell me what the issue was? I have the same exact problem but couldn't figure out why it behave that way. I'm restricted to Ext 2.2.1

Thanks

KNS
23 Sep 2011, 10:07 AM
got it!

the fix:

Ext.getCmp('myGrid').getBottomToolbar().pageSize = ParseInt(myNewPageSize,10);


Looks like the pagingToolbar takes my newPageSizeValue from the textField as a String instead of a number, so PagingToolbar does an
myNewPageSize(String) + existing PageSize(Int), there for the count messed up!

Hope it'd help someone, because it drove me nut!