Can I move to last page in xaml

11 posts, 1 answers
  1. Daniel Billingsley
    Daniel Billingsley avatar
    95 posts
    Member since:
    Apr 2010

    Posted 14 Jul 2010 Link to this post

    Is there a way to set the pager so it will move to the last page the first time the hosting page is displayed?  No, I don't want to just sort in the other order... I want ascending sorting but moved to the last item in the list.

    If that's not possible, what's the best way to do this in code behind?  What event should I hook to?
  2. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 15 Jul 2010 Link to this post

    Hello Daniel Billingsley,

    The easiest way would be to set it in the code behind like so:

    Snippet
    dataPager.PageIndex = dataPager.PageCount - 1;

    Hope this helps.

    Regards,
    Veskoni
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
  4. Daniel Billingsley
    Daniel Billingsley avatar
    95 posts
    Member since:
    Apr 2010

    Posted 15 Jul 2010 Link to this post

    Yes, I realize I could do that, but I need to make sure I get that after the data is loaded and the pager has had a chance to "pagify" it based on the sorting, etc.  Is there an event the control raises that would tell me it's safe to move to the last page?
  5. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 15 Jul 2010 Link to this post

    Hello Daniel Billingsley,

    You can use this line of code after you set the Source property of the DataPager:

    dataPager.Source = GetData();
    dataPager.PageIndex = dataPager.PageCount - 1;


    Hope this helps.

    Kind regards,
    Veskoni
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Daniel Billingsley
    Daniel Billingsley avatar
    95 posts
    Member since:
    Apr 2010

    Posted 15 Jul 2010 Link to this post

    Well, that's the problem.  The source is simply bound to the ViewModel with Xaml.  Would the DataPager already have its source by the time of the OnNavigatedTo method on the page?

    I'm loading the data async of course, so I guess what I need to do is add a DataLoaded event to the ViewModel and then handle this in the page's code behind.
  7. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 16 Jul 2010 Link to this post

    Hi Daniel Billingsley,

    Can you please give us some more information so we can have the big picture before we try to find a solution.
    Do you load the data with DomainDataSource?

    Regards,
    Veskoni
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  8. Daniel Billingsley
    Daniel Billingsley avatar
    95 posts
    Member since:
    Apr 2010

    Posted 16 Jul 2010 Link to this post

    No, I'm using the CSLA framework.  The Model object for this page is a CSLA collection class.

    The page has a RadGridView bound to a RadDataPager, which is turn bound to a property on the ViewModel that exposes the underlying collection.  The async load is fired in the OnNavigatedTo event, and the retrieved collection is set when it's retrieved.

    So, certainly the ViewModel knows when the data has been retrieved, but it shouldn't be interacting with controls in a specific view, of course.

    So, I need something in the View that tells me the data source has been set, right?  I don't see any such event on the data pager.
  9. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 16 Jul 2010 Link to this post

    Hello Daniel Billingsley,

    You can TwoWay bind the PageIndex dependency property of the pager to the respective property on your model. Your int field in the view model should start as -1, which is the default value for the pager when there is no source defined.

    Since you mentioned that inside your view model you know when data has arrived, you can change the PageIndex of the view model at this point of time. Since it is bound two-way, the pager will move to the last page.

    Will this work for you?

    Best wishes,
    Ross
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  10. Answer
    Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 16 Jul 2010 Link to this post

    Hi Daniel Billingsley,

    I invented another approach.

    The pager is "born" with page index -1. As soon as everything is ready and the source is processed, it automatically displays the first page (index 0). You can use this fact by attaching to the PageIndexChangedEvent and detect that args.OldPageIndex == -1 and args.NewPageIndex == 0. This will indicate that the pager is up, running and ready to use for the first time.

    You can simply call its MoveToLastPage method when this happens. I think that this approach will be better.
     
    Sincerely yours,
    Ross
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  11. Daniel Billingsley
    Daniel Billingsley avatar
    95 posts
    Member since:
    Apr 2010

    Posted 16 Jul 2010 Link to this post

    Yes, that sounds perfect. 

    (I didn't like your first idea because that would mean the ViewModel would need to know about a specific control on a specific View.)
  12. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 09 Sep 2010 Link to this post

    Hi Daniel Billingsley,

    With the Latest Internal Build that will be released tomorrow, we have added batch initialization support for RadDataPager in XAML. We have implemented the ISupportInitialize interface and now the order in which properties are defined in XAML should not matter anymore.

    The Latest Internal Build will be released tomorrow. Could you please test with it and let us know if there are any problems left.

    Regards,
    Ross
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top
DevCraft banner