I want to change radgrid default pageSize programmatically. Basically I want to give different radgrid PageSizes to different users.
after reloading the page it goes back to original default pageSize.
I'm using < PagerStyle Mode="NextPrevNumericAndAdvanced" .
I don't want to use RadComboBox dropdown for pageSize.
Cheers
6 Answers, 1 is accepted
Hi,
You can define the page size via myRadGRID.MasterTableView.PageSize .
I didn't see any properties in the master grid and in the pagestyler that disable the 'PageSize Selector'.
But you can build your own Pager with PagerTemplate
I hope this help,
Regards,
Pierre
Hi Pierre,
Thank you for the reply. myRadGRID.MasterTableView.PageSize is perfect.
Now i can set the page size what i want.
how can i take the pageSize to save in DB?
these a, b or c doest give the current page size. Those gives only default pageSize.
int a= myRadGRID.PageSize;
int b = myRadGRID.MasterTableView.PageSize;
RadNumericTextBox c= (RadNumericTextBox)e.Item.FindControl("ChangePageSizeTextBox");
same time i want to get the pageNum as well, which always gives 1 even after it change...
RadNumericTextBox pageNum = (RadNumericTextBox)e.Item.FindControl("GoToPageTextBox");
Please help me..
Cheers
Has
Hi,
myRadGRID.PageCount:
When the paging feature is enabled (by setting the AllowPaging property to
true), use the PageCount property to determine the total number of pages
required to display the records in the data source. This value is calculated
by dividing the total number of records in the data source by the number
of records displayed in a page (as specified by the PageSize property) and
rounding up.
Regards,
Pierre
Hi Pierre,
Thanks for the reply.
1) I used 3 ways to get the Current Page Size But always a, b and c is equal to the Default pageSizes not the current page Size. I written these below codes under gridDevices_PreRender() and gridDevices_ItemCreated() functions. :(
int a= myRadGRID.PageSize;
int b = myRadGRID.MasterTableView.PageSize;
RadNumericTextBox c= (RadNumericTextBox)e.Item.FindControl("ChangePageSizeTextBox");
2)RadPersistenceManager1.SaveState(); also saves the default pageSize Which is Set in .aspx file(pageSize="8") . I want to take the Current PageSize not the Default one.
3) int d= myRadGRID.PageCount;
int e= myRadGRID.MasterTableView.PageCount;
also never gives the pageCounts properly.
help me please ...
Cheers
Has
Hi,
1. Yes, PageSize Contains the Default Value (10) .
But I see what you mean.
In GridPrerender, PageSize will be equal to 10 no matter what.
Then ' PageSize="20" ' that you set in the MasterTableView is set.
So the grid has a PageSize Set to 20; After this every time you ask for the PageSize you will have the current Value.
You should not set PageSize is the aspx of your MasterTableView, if you want do have custom Pagesize do it in code behind.
2. I dont know the SaveState.
3. myRadGRID.PageCount; and myRadGRID.MasterTableView.PageCount;
Work every time for me , in pre render or on a button .
Hi Pierre,
1,3) I thing you use _NeedDataSource() to get data right? Im using like this.
<DataBinding Location="webservicePage.asmx" SelectMethod="GetMyWebMethod" SelectCountMethod="SessionExpired">
</DataBinding>
however I'm not getting the Current PageSize or Current PageCount with above functions which gives me default values,. :(
-------------
2) Please check Button1_Click() in this Demo.. it says PageSize is saving RadPersistenceManager1.SaveState(); it save the default pageSize not the Current PageSize. here is the link....
https://demos.telerik.com/aspnet-ajax/controls/examples/integration/persisting-grid-settings/defaultcs.aspx?product=grid
Please help me
Cheers
Has