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

Setting the PageIndex in code behind and calling PageIndexChange event

2 Answers 48 Views
DataPager
This is a migrated thread and some comments may be shown as answers.
Mathieu
Top achievements
Rank 1
Mathieu asked on 17 Feb 2012, 04:16 PM
Hi,

I am using the RadDataPager control in a grid manually without setting a PagedSource or a Source. I have a ViewModel Command connected to the PageIndexChange using a behavior I created and it works fine, but in the code-behind of my view I set the PageIndex of the control to 0 sometimes. This doesn't trigger the event, and in another thread it was said that this was by design, that only when the PageIndex is changed by the control itself it triggers.

What I would expect though would be the event being called when the PageIndex is changed, whoever changed it. How could I get my Command to be called when I set the PageIndex myself without breaking the MVVM pattern? What I want to avoid is this in the code-behind of my view but it's the only thing I can think of to do what I want :

public void ResetDataPager()
{
    if (DataPager.PageIndex > 0)
    {
        DataPager.PageIndex = 0;
        // not MVVM
        var vm = (MyViewModel)DataPager.DataContext;
        vm.ChangePageIndex.Execute(DataPager.PageIndex);
    }
}

Do you have any idea how I can achieve this?

2 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 17 Feb 2012, 04:20 PM
Hi,

Can you open a new support ticket and send us a very dummy sample project with your exact implementation so we can take a look at it. Thanks in advance.

Regards,
Ross
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
BHARATH
Top achievements
Rank 1
answered on 08 Mar 2017, 12:26 PM

Hi,

I have a requirement in telerik RaddataGRid as "When we are in the Last page of the grid if we click on next button or last  in the pager i have to move to the first page and if i am in the first page if i click on the previous button then i have to move to the  last page. " I am not getting it how to do. I used PageIndexChanging  and PageIndexChanged Events and tried to set the newPageIndex and old PAge Index but i am not able to do it. As i am new here Please suggest how to do this As it is urgent requirement for me.

 

Tags
DataPager
Asked by
Mathieu
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
BHARATH
Top achievements
Rank 1
Share this question
or