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

[Solved] Only display top 3 rows of results

3 Answers 125 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jonathon
Top achievements
Rank 1
Jonathon asked on 22 Aug 2011, 07:31 PM
Hi,

I was wondering, how would I display only the top 3 rows? The GridView is in a small area and I want to do something similar to RadDataPager's PageSize="3" without actually displaying anything other than the GridView. RadDataPager has DisplayMode, however, there is no "None" option.

Thanks,

Jonathon

3 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 22 Aug 2011, 09:00 PM
Hi Jonathon,

RadGridView.Items implements the IPagedCollectionView interface, so you could try setting RadGridView.Items.PageSize to 3. You will be paging the grid without a pager. In fact, RadDataPager uses this interface to "communicate" its paging instructions to RadGridView. But you can take its place and issue all paging commands by hand if you want to. Take a look at the IPagedCollectionView interface for more info.

Alternatively, you can leave only the first three rows in your source collection and RadGridView will display only those 3 rows. You can use LINQ to do something like sourceCollection.Take(3) which will take only the first three records.

I hope this helps.

All the best,
Ross
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Jonathon
Top achievements
Rank 1
answered on 22 Aug 2011, 09:28 PM
Thanks.

I was wondering, is there a way to use IPagedCollectionView you showed first using MVVM so I don't have any code behind?

Jonathon
0
Rossen Hristov
Telerik team
answered on 23 Aug 2011, 06:46 AM
Hi Jonathon,

I don't think so.

Anyway, MVVM is not a synonym for "absolutely no code-behind". Sooner or later you eventually reach some code-behind that does all the job. In most cases that would be the code-behind of the framework or of our controls, but in some cases it will be yours. You can "hide" your code-behind by using attached behaviors if you wish. The you won't have any code-behind on your page, since it will be in your attached behavior. But it has to be somewhere.

I hope this makes sense.

Regards,
Ross
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
GridView
Asked by
Jonathon
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Jonathon
Top achievements
Rank 1
Share this question
or