This is a migrated thread and some comments may be shown as answers.

RadGrid PageSize and CurrentPageIndex changing in codebehind not working

5 Answers 168 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alexander
Top achievements
Rank 1
Alexander asked on 03 Sep 2014, 07:25 PM
I have a RadGrid that I would like to change the size of the page and the current page number depending on the URL.

I can query the URL and retrieve the data that I would like, and attempt to apply it like so:

Dim pageSize As Integer = 10
Dim pageNum As Integer = 0
If Request.QueryString("PageSize") IsNot Nothing Then
    pageSize = Request.QueryString("PageSize")
    rgvListObservations.PageSize = pageSize
    rgvListObservations.Rebind()
End If
If Request.QueryString("PageNum") IsNot Nothing Then
    pageNum = Request.QueryString("PageNum")
    rgvListObservations.CurrentPageIndex = pageNum
    rgvListObservations.Rebind()
End If


I do this in the Page.PreRender. The CurrentPageIndex will save correctly, but unfortunately the PageSize does not change.

I have attempted to paste this code into the function I call to fill the grid as well as the NeedDataSource(of course removing the rebind call) to no avail.

I am just wondering why one would save but not the other? Also I would like to know if I am attempting to change the PageSize in the backend correctly.

5 Answers, 1 is accepted

Sort by
0
Alexander
Top achievements
Rank 1
answered on 03 Sep 2014, 09:32 PM
I found out why my RadGrid isn't saving the PageSize. Before I change the PageSize I load the RadPersistenceManager and plug in the data for my grid. If my saved grid data had a 10 page size while my URL page size said 20, it would always take the saved grid page size.


 Is there a way that I can load my RadPersistenceManager and then load the data from my URL?
0
Alexander
Top achievements
Rank 1
answered on 03 Sep 2014, 09:39 PM
Okay so I just kinda finagled my way through this.

Instead of taking out the RadPersistenceManager or anything like that, what I did was this:

Before I loaded my data into the RadPersistenceManager I had it query the URL for a PageSize. If it found one, it would then add that to the grid, and save the grid settings through the RadPersistenceManager.

I then loaded the RadPersistenceManager and it worked. If I didn't do that it would never take the new PageSize.
0
Wired_Nerve
Top achievements
Rank 2
answered on 03 Oct 2014, 02:45 PM
Do you have any sample code on how you set the radgrid pager size?
0
Wired_Nerve
Top achievements
Rank 2
answered on 03 Oct 2014, 02:46 PM
as it relates to the RadPersistenceManager

0
Konstantin Dikov
Telerik team
answered on 08 Oct 2014, 12:30 PM
Hello,

As you can see in our online demo for Persisting Grid Settings, the page size is correctly saved and load through the RadPersistenceManager.

If you have something else in mind, could you please elaborate on your exact requirement and what you are trying to achieve.

I am looking forward to your reply.


Regards,
Konstantin Dikov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Alexander
Top achievements
Rank 1
Answers by
Alexander
Top achievements
Rank 1
Wired_Nerve
Top achievements
Rank 2
Konstantin Dikov
Telerik team
Share this question
or