RadGridViewCommand BeginInsert with DataPager

4 posts, 0 answers
  1. Ricky
    Ricky avatar
    21 posts
    Member since:
    Feb 2011

    Posted 10 Jun 2014 Link to this post

    I am using the RadGridViewCommand BeginInsert with a RadGrid that uses a DataPager. 

    I used the AddingNewDataItem completed event to attempt to move the datapager to the last page to accommodate multiple pages. When adding the item to increase the page size from 1 to 2 pages, the AddingNewDataItem event fires to move the DataPager to the last page. However, at that moment the page size is still 1.

    How can I use the RadGridViewCommand BeginInsert and use multiple pages? 

    Also is there a way to use the RadGridViewCommand BeginInsert to insert to the beginning of the list rather than the end?
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 13 Jun 2014 Link to this post

    Hi,

    You cannot insert at the beginning of the list using the BeginInsert command.
    You can check the Insert New Row into Paged GridView help article, however the page size will not be changed until adding the new item has been committed.

    Regards,
    Didie
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. DevCraft banner
  4. Ricky
    Ricky avatar
    21 posts
    Member since:
    Feb 2011

    Posted 13 Jun 2014 in reply to Dimitrina Link to this post

    Hi Didie,

    Thanks for the reply. I have tried that code from the article before posting:

    private void clubsGrid_AddingNewDataItem(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e)
        {
            ((RadGridView)sender).Items.MoveToLastPage();
        }

    As you mentioned, at the time that the GridViewAddingNewEventArgs is triggered, the new item still hasn't been committed. In the example of adding the next item that would increase the page size from 1 to 2, the code from the example would leave the user on the first page.

    Is there any other event fired that pager.MoveToLastPage() could be used to get the desired effect of moving to the last page in this example?
  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 17 Jun 2014 Link to this post

    Hi,

    There is not another event I can suggest. You can try executing the code for moving to the last page in a Dispatcher.
    For example:
    private void clubsGrid_AddingNewDataItem(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e)
    {
      Dispatcher.BeginInvoke(new Action(()=>{
     
        ((RadGridView)sender).Items.MoveToLastPage();
    }));
    }

    Let me know how this works for you.

    Regards,
    Didie
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
Back to Top