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

[Solved] Horizontal Paging

3 Answers 111 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steven Black
Top achievements
Rank 1
Steven Black asked on 22 Oct 2009, 08:05 PM

I'm interested in setting up a grid that will have a random number of columns, although the first column will always be the same.  I want the first column to be frozen, and then I want to only show 5 additional columns at a time.  I do not want a horizontal scrollbar though.  Instead, I want to use the paging control.  Page one would should the frozen column plus the first 5 additional columns.  Page 2 would show the frozen column plus the 2nd 5 additional columns, and so on.

Can this be done?  If so, can you please provide some assistance?

Thanks.

Steve

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 23 Oct 2009, 08:05 AM
Hello Steve,

I found the following forum link which discusses on a similar requirement as yours and it seems that paging on a per column basis is not possible in grid. Here's the link:
How to Paging in Vertical Rad Grid

Regards
Princy.
0
Pavlina
Telerik team
answered on 23 Oct 2009, 09:03 AM
Hello Steven,

In order to achieve the desired functionality I suggest that you use PagerTemplate which fulfills your requirements. Please have in mind that you need to set PagerStyle-AlwaysVisible property of RadGrid to true, after that you could handles on ItemCommand event and cancel paging. Then you will need to apply your custom code logic which to produce the desired effect.

Sincerely yours,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Steven Black
Top achievements
Rank 1
answered on 26 Oct 2009, 02:44 PM

Thanks to both of you for your suggestions.  I was able to do this a different way though that utlizes the inherent pager functionality.  My workaround is only feasible because I will never have more than about 20-30 rows, so we're not talking about a grid with a large data set.

This is what I am doing:

First I determine how many rows I have.  Let's assume I have 20 rows.  Then I figure out how many horizontal "pages" I need.  For instance, if I have one frozen column plus 13 other columns, and I only want to show five of those at a time, I'll need 3 pages (5, 5, 3).

I then added my 20 rows repeatedly back into my result set (using the same sort order).  So in this case I'm returning 60 rows from my stored procedure instead of 20, and of course I'm making my page size on the grid be 20.  So, when the users goes to Page 2, they are technically going to rows 21-40, which are identical to rows 1-20.  If they go to Page 3, they are seeing rows 41-60, which again are identical to 1-20.

Now the only thing left to do is show or hide the appropriate columns when the page index changes.  This actually gets done in the ItemDataBound event (because the Columns collection does not include my auto-generated columns). 

Everything is working perfectly.  Perhaps this can help somebody else.

Thanks again.

Steve
Tags
Grid
Asked by
Steven Black
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Pavlina
Telerik team
Steven Black
Top achievements
Rank 1
Share this question
or