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

Can I move to last page in xaml

10 Answers 85 Views
DataPager
This is a migrated thread and some comments may be shown as answers.
Daniel Billingsley
Top achievements
Rank 1
Daniel Billingsley asked on 15 Jul 2010, 03:22 AM
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?

10 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 15 Jul 2010, 08:01 AM
Hello Daniel Billingsley,

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

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
0
Daniel Billingsley
Top achievements
Rank 1
answered on 15 Jul 2010, 02:48 PM
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?
0
Veselin Vasilev
Telerik team
answered on 15 Jul 2010, 02:54 PM
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
0
Daniel Billingsley
Top achievements
Rank 1
answered on 15 Jul 2010, 04:36 PM
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.
0
Veselin Vasilev
Telerik team
answered on 16 Jul 2010, 10:08 AM
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
0
Daniel Billingsley
Top achievements
Rank 1
answered on 16 Jul 2010, 12:40 PM
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.
0
Rossen Hristov
Telerik team
answered on 16 Jul 2010, 01:13 PM
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
0
Accepted
Rossen Hristov
Telerik team
answered on 16 Jul 2010, 01:27 PM
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
0
Daniel Billingsley
Top achievements
Rank 1
answered on 16 Jul 2010, 01:34 PM
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.)
0
Rossen Hristov
Telerik team
answered on 09 Sep 2010, 12:38 PM
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
Tags
DataPager
Asked by
Daniel Billingsley
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Daniel Billingsley
Top achievements
Rank 1
Rossen Hristov
Telerik team
Share this question
or