toolbar pager, how to set perpagenum ?

Hello,

I have a grid with toolbar style pager, I need to save in cookies perpage number (perpagenum) and then after grid loaded I need to set perpagenum from cookies.
E.g. I want to show 20 records on page instead of 5 (by default) and if I select 20 I write it to cookie with no problem, but how can I load pager with this value (perpagenum=20).

var tb=this.descrGrid.aToolBar;
tb.attachEvent("onClick", function(itemId){
	var item = itemId.split('_');
	if(item[0] == 'perpagenum') {
		Cookie.write('pageSize', item[1], {duration: 365});
	}
});
var pageSize = Cookie.read('pageSize'); // get size from cookie
// i tryed next line, but it doesn't load the pager and selects value in list only
tb.setListOptionSelected('perpagenum', 'perpagenum_' + pageSize); // doesn't help

Please advise.

Thank you.
Alex.

Hello guys?

You can change page with API:

grid.changePage(20);

Hi Olga,

I don’t need to change page, I have to change rows_per_page value on grid load.

Please advise.
Thank you.
Alex.

Try to use following code:

mygrid.loadXML("../common/500.xml",function(){ var toolbar=mygrid.aToolBar; toolbar.setItemText("perpagenum","5 rows per page"); mygrid.rowsBufferOutSize = 5; mygrid.changePage(0) });

Thanks Olga, thats working fine and even the next line

toolbar.setItemText("perpagenum","5 rows per page");

is not necessary.

I finally found out how to change the page select quantities from “5, 10, 15, 20, 25, 30” to what I needed.

All I needed to do was call “setPagingWTMode(true,true,true,[30,60,90,120])” before “enablePaging()” and the toolbar had my values in it.

I’m using the toolbar paging skin “setPagingSkin(‘toolbar’,‘dhx_skyblue’)”] so this might not work if a different skin is used.