Setting the PageIndex in code behind and calling PageIndexChange event

3 posts, 0 answers
  1. Mathieu
    Mathieu avatar
    1 posts
    Member since:
    Oct 2011

    Posted 17 Feb 2012 Link to this post

    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. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 17 Feb 2012 Link to this post

    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 >>
  3. BHARATH
    BHARATH avatar
    1 posts
    Member since:
    Mar 2017

    Posted 08 Mar Link to this post

    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.

     

Back to Top