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

Setting Page Size when using Custom Paging

4 Answers 154 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Levi
Top achievements
Rank 1
Levi asked on 30 Oct 2008, 07:10 PM
I setup a pager template per your example at:
http://demos.telerik.com/ASPNET/Prometheus/Grid/Examples/Programming/PagerTemplate/DefaultCS.aspx

This works fine by itself. I can set the page size successfully and the grid will change to the appropriate number of rows. I then implemented custom paging in order to speed up the database calls per your example at:
http://demos.telerik.com/ASPNET/Prometheus/Grid/Examples/Programming/CustomPaging/DefaultCS.aspx

For some reason the page size is not getting saved, so the when the post back occurs it still shows ten. This javascript function from the 2nd is example is getting called in both cases, but on the page load of the post back the first contains the updated page count while the other does not. Does custom paging keep this feature from working? If so is there a different way I should be setting the page count when using custom paging?

Thanks!
Levi

4 Answers, 1 is accepted

Sort by
0
Accepted
Rosen
Telerik team
answered on 03 Nov 2008, 12:49 PM
Hello Levi,

Are you using the same code from the CustomPaging example? If this is true, please change the NeedDataSource event's code to use RadGrid's MasterTableView's PageSize property instead the RadGrid's one, as this is the property which value is changed through the pager's dropdown. Thus your NeedDataSource event's handler's code should look similar to the following:

protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e)  
        {  
            MyBusinessObjectCollection MyBusinessObjectCollection1 = new MyBusinessObjectCollection();  
            int startRowIndex = (ShouldApplySortFilterOrGroup()) ?  
                0 : RadGrid1.CurrentPageIndex * RadGrid1.MasterTableView.PageSize;  
 
            int maximumRows = (ShouldApplySortFilterOrGroup()) ?  
                MyBusinessObjectCollection1.SelectCount() : RadGrid1.MasterTableView.PageSize;  
 
            RadGrid1.AllowCustomPaging = !ShouldApplySortFilterOrGroup();  
 
            RadGrid1.DataSource = MyBusinessObjectCollection1.Select(startRowIndex, maximumRows);  
        } 

Please give it a try and let us know if this helps.

Kind regards,
Rosen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Levi
Top achievements
Rank 1
answered on 03 Nov 2008, 02:13 PM
That fixes the problem. Thanks!

Levi
0
Tonino
Top achievements
Rank 1
answered on 21 Nov 2013, 01:11 PM
Hello!

Please change the code at http://demos.telerik.com/ASPNET/Prometheus/Grid/Examples/Programming/CustomPaging/DefaultCS.aspx according to the answer of Rosen (use RadGrid1.MasterTableView.PageSize instead of RadGrid1.PageSize).

I had the same problem because I copied the code from the demo pages...

Regards,
Tonino.
0
Konstantin Dikov
Telerik team
answered on 26 Nov 2013, 08:55 AM
Hi Tonino,

Please note that the initial post was for our old ASP.NET controls. As you could see from our online demo, the custom paging is working as expected with that approach and there is no reason to change anything.

If you have experienced some difficulties with our demo and our latest versions, could you please elaborate about your exact scenario, so we could investigate this further.

Looking forward to your reply.


Regards,
Konstantin Dikov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Levi
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Levi
Top achievements
Rank 1
Tonino
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or