Service-oriented DataPager without WFC RIA

7 posts, 1 answers
  1. Lars
    Lars avatar
    4 posts
    Member since:
    Nov 2010

    Posted 22 Dec 2010 Link to this post

    How would you go about making serverside paging, without using the WFC RIA architecture?
    We have an existing project, where we want to use RadGridView and RadDataPager, instead of the current standard gridview and pager,
    and i have played around a bit with some ideas to make "custom" serverside paging. I can't get it to work.

    Do you have any pointers on where to start? And is this supported "out of the box" in the RadDataPager, if so, where should i be looking?

    E.g. 20 items per page, 200 items in all:
    My own solution, which is not working, is to get 20 items from the service, and also get the total item count. Then i calculate how many items, depending on the pageindex, there are before and after the current page of 20 items, and add 'N' number of bogus item as fillers, to let the DataPager calculate number of pages total. E.g. pageindex = 3 (page 4) i would have 60 bogus items at the start of the source collection, the the 20 'real' items, and after these i would have 120 more bogus items.

    But when i update the Source collection of the datapager and gridview, its seems to reset its pageindex. Im listening on the DataPagers PageIndexChanging event, and update the source collection during this event.

    Looking forward to some feedback.

    Regard,
    Lars Udengaard
  2. Answer
    Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 22 Dec 2010 Link to this post

    Hello Lars,

    The bogus items are not longer needed since the pager has a feature called Unbound Mode.

    I would do the following:

    1. Use RadDataPager in UnboundMode. That means that it will not have its Source property defined. When in Unbound Mode, you can tell the pager the total number of items by setting its ItemCount property. It will then do the math according to the ItemCount and PageSize and update its UI.

    2. Then attach to the PageIndexChanged event. You will receive the page index that the user is requesting.

    3. Fetch the respective page data from your service and as soon as it arrives on the client -- set it as the ItemsSource of RadGridView.

    In fact RadGridView will never have a clue what is really going on and that there is server-side paging.

    As for RadDataPager, you will be using this control solely for its UI. Its built-in paging capabilities will not be used since it will be in Unbound Mode, i.e. Source = null.

    Let me know if there are problems.

    Regards,
    Ross
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  3. DevCraft banner
  4. Lars
    Lars avatar
    4 posts
    Member since:
    Nov 2010

    Posted 22 Dec 2010 Link to this post

    That was exactly the kind of nifty feature i was looking for.
    Thank you for the quick response, and good products.

    Regards,
    Lars
  5. Lars
    Lars avatar
    4 posts
    Member since:
    Nov 2010

    Posted 22 Dec 2010 Link to this post

    Im using MVVM and tt doesnt look like you can bind ItemsCount, is this correct? Do you have to set it in codebehind?

    /Lars
  6. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 22 Dec 2010 Link to this post

    Hi Lars,

    This is an issue that we are currently working on. You can vote for and follow its status here.

    Until we resolve the issue you should set the ItemCount in code-behind.

    Greetings,
    Ross
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  7. Lars
    Lars avatar
    4 posts
    Member since:
    Nov 2010

    Posted 22 Dec 2010 Link to this post

    Ok, Thanks! Happy holidays ;-)
  8. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 23 Dec 2010 Link to this post

    Hello Lars,

    I have fixed the ItemCount Binding and it will work as expected when we release the next "Latest Internal Build". It will not be able to make it for the SP coming out this week since we have already frozen the source code for this release.

    Kind regards,
    Ross
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
Back to Top
DevCraft banner