Custom paging with Telerik RadGridView and RadDataPager for Silverlight and Microsoft Visual Studio 2012 LightSwitch

by Vladimir Enchev | Comments 17

With this post I would like to show you how you can customize easily paging behavior in Microsoft Visual Studio 2012 LightSwitch using Telerik RadDataPager for Silverlight.

1) Create new LightSwitch project, connect to desired data source and add new screen:

LS1

LS2

LS3

2) Add new Silverlight Class Library to the same solution where you can implement your own custom logic:

LS4

LS5

3) Add references to Telerik and LightSwitch binaries and declare RadGridView and RadDataPager:

LS6

LS7

4) Add your custom control in the LightSwitch screen:

LS8

LS9

5) Implement your custom logic, in this case custom, server-side paging, and run the application to check the result:

LS13

LS11

LS12

Enjoy!

Download

,
Senior Technical Architect

17 Comments

Heysol
Excellent this help me a lot, congrats for this post.  how do i customize my RadGridview columns and how do i  add RadGridView.columnGroups
Thanks
Rodney Joyce
Thanks Vlad - however, I need to get rid of the flashing each time it pages - http://screencast.com/t/9KrHPJwdWh 
Vlad
Hi Heysol,
Please check our demos and documentation for more info on how to customize columns and column groups.
Vlad
Hi Rodney,
It seems that when you change IScreenCollectionProperty  
PageNumber property you are forcing update of the whole content item (IContentItem) where the grid and the pager are located - not sure why LightSwitch team decided to do this (personally I don's see any real reason). I didn't liked also the fact that you cannot simply bind (TwoWay) all properties like in any other MVVM scenario. While you can bind PageSize and PageNumber (not zero based and you need to use at least IValueConverter) the PageCount cannot be bound - the binding will not receive PropertyChanged event and will never be updated. For sure the ideal solution will be if we can have standard IPagedCollectionView exposed instead custom properties related to paging, etc. 
Heysol
Perfect it works correctly !!! Just a question my DataPager appears in the middle of the grid. Does this happen because im using a trial ? or how do i place it at the bottom.
Thanks
Heysol
Perfect it works correctly !!! Just a question my DataPager appears in the middle of the grid. Does this happen because im using a trial ? or how do i place it at the bottom.
Thanks
afateen
Nice sample.  Sorting and filtering are working only on the selected page.  How can we get sorting and filtering to work on the entire dataset (i.e. across multiple pages)?



Thanks
Vlad
Hi Heysol,
Are you using the the layout from my application? In my demo I have a Grid with two row definitions (the second is with Auto Height) -  RadGridView is associated with the first row and RadDataPager with the second row.
Vlad
Hi afateen,
Indeed server-side sorting, filtering, grouping and paging is possible and I will create separate blog post with more info how this can be achieved. The idea is to consume the oData services exposed by LightSwitch and bind everything using RadDataServiceDataSource:
http://demos.telerik.com/silverlight/#DataServiceDataSource/FirstLook
Heysol
Yes, I used the same example maybe something is wrong because it sends and error Objcet reference not set to an instance of an object, this appears when i place the  <telerik:RadGridView.Columns> 
i placed this as you showed in your post 
 
<Grid.RowDefinitions>
 <RowDefinition /> 
 <RowDefinition Height="Auto" />
</Grid.RowDefinitions>

but appears in the middle What can i do ?
Heysol
I solve it i place Grid.Row="0" in the grid and Grid.Row="1" in the Datapager and works thanks for this post
Norom
Talking about server-side/client-side sorting and filtering is simply amazing. It's 2012, you know? 
And, putting screenshots of code is ingenious. You are a components shop, are you not? If you are so incompetent that you cannot write your own code formatter, there are free ones around the net.
afateen
Vladimir,  that would be great!  I look forward to that blog post.

Thanks
Vlad
Hi Norom,I'm sure it will be better if you write the code by yourself instead copy/paste someone else code.
Rodney
Hi again Vlad, I patiently await another blog post on how to do server side paging/sorting/grouping etc. as you describe (and I am sure others do to ;)
Vlad
Hi Rodney, I was off the office this week, however next week I'll publish the next post :)
Vlad
Hi,
I've just published my next blog post on how to consume LightSwitch OData services using RadDataServiceDataSource for Silverlight.
Thanks

Comments

  1.    
      
      
       
  2. (optional, emails won't be shown on public pages)
  3. (optional)
Read more articles by Vladimir Enchev - or - read latest articles in Developer Tools


Follow vladimir_enchev on Twitter


Product Families