Prevent Losing Batch Editing Changes on Paging or any other PostBack

Thread is closed for posting
7 posts, 0 answers
  1. 63F75A2C-1F16-4AED-AFE8-B1BBD57646AD
    63F75A2C-1F16-4AED-AFE8-B1BBD57646AD avatar
    1572 posts
    Member since:
    Oct 2004

    Posted 27 Feb 2014 Link to this post

    Requirements

    .NET version

     3.5+

    Visual Studio

     2010+

    programming language

     JavaScript

    browser support

     all browsers supported by Telerik UI


    PROJECT DESCRIPTION

    When using a RadGrid with enabled Batch editing functionality, it is possible to forget or neglect saving the recent changes before moving to another page, sorting, filtering or any other Postback action. This code-library demonstrates how to prevent the action if there are any unsaved Batch changes. It provides four approaches to choose from depending on your specific requirements:
    • SimpleStandardConfirm: The most basic implementation which prevents only paging.
    • SimpleRadConfirm: Prevents only paging, but this time with RadWindow.
    • AdvancedStandardConfirm: Demonstrates how to prevent paging, sorting, other PostBack actions from external elements, as well as, closing the browser or navigating to another page without saving the changes.
    • AdvancedRAdConfirm: The same as AdvancedStandardConfirm, but using RadWindow confirmation wherever possible.

    You can find additional information about the Advanced confirm pages in the comments of their respective script files.


     
  2. 9A9400D6-8C2A-4DE0-B31E-2475AB534643
    9A9400D6-8C2A-4DE0-B31E-2475AB534643 avatar
    10 posts
    Member since:
    May 2012

    Posted 17 Nov 2014 Link to this post

    The advanced samples are not working. If i edit the data then it refreshes it to the value before and nothing happens. What´s wrong?
  3. DF7D1A30-6166-46E3-8A25-1BDF36B1ACD1
    DF7D1A30-6166-46E3-8A25-1BDF36B1ACD1 avatar
    1155 posts
    Member since:
    May 2017

    Posted 20 Nov 2014 Link to this post

    Hello Ralf,

    Actually the sample only shows how to prevent the user from performing an action that would lead to the loss of the current changes. However the example does not illustrates how to save the user changes. In order to achieve this you can follow one of the following approaches.
    1. Bind the grid to a data source control that supports automatic operations as demonstrated here.
    2. Subscribing to the OnBatchEditCommand event, extracting the user changes from the arguments and manually update the database/data source to which the grid is bound. An example on how to access the values from the event arguments is provided here.
    3. If client-side binding will be used you can bind the grid to a RadClientDataSource and enable its batch operations. Possible realization of this scenario can be observed here.


    Regards,
    Angel Petrov
    Telerik
     
    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 Feedback Portal and vote to affect the priority of the items
     
  4. B921FABB-2310-45F4-8ABA-DCBE3E0D7221
    B921FABB-2310-45F4-8ABA-DCBE3E0D7221 avatar
    31 posts
    Member since:
    Mar 2014

    Posted 24 Feb 2015 in reply to 63F75A2C-1F16-4AED-AFE8-B1BBD57646AD Link to this post

    Hello Telerik Admins,

    thanks a lot for providing the Sample Code. Unfortunately, I'm running into a loop when using it. On using the change-page-buttons (not the numbers!), javascript shows the error "script28: Not enough stack memory".

    Any idea why this could happen and how to solve it?

    Any help would be very appreciated!

    Thanks in advance

    Jan
  5. 4513861F-C564-42D2-BC9F-5FAED19E993E
    4513861F-C564-42D2-BC9F-5FAED19E993E avatar
    4090 posts
    Member since:
    Apr 2022

    Posted 24 Feb 2015 Link to this post

    Hi Jan,

    The recent release version of the controls introduced a new OnUserAction client-side event handler which makes this requirement a much more straightforward task. You can subscribe to this handler and cancel it depending on some specific conditions:
    http://demos.telerik.com/aspnet-ajax/grid/examples/data-binding/client-side/client-data-source-binding/defaultcs.aspx?product=clientdatasource

    This remove the necessity of including complex javascript logic to achieve this requirement.

    Hope this helps.


    Regards,
    Eyup
    Telerik
     
    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 Feedback Portal and vote to affect the priority of the items
     
  6. B921FABB-2310-45F4-8ABA-DCBE3E0D7221
    B921FABB-2310-45F4-8ABA-DCBE3E0D7221 avatar
    31 posts
    Member since:
    Mar 2014

    Posted 24 Feb 2015 in reply to 4513861F-C564-42D2-BC9F-5FAED19E993E Link to this post

    Hello Eyup,

    thanks a lot! I've achieved the desired behaviour using this (few) lines of code. I wanted the RadGrid to save automatically all changes if paging and wished by the user:
    function UserAction(sender, args) {
                if (sender.get_batchEditingManager().hasChanges(sender.get_masterTableView())) {
                    if (confirm("Änderungen müssen vor Seitenwechsel gespeichert werden! Fortfahren?")) {
                        sender.get_batchEditingManager().saveChanges(sender.get_masterTableView());
                        args.set_cancel(true);
                    }
                    else {
                        args.set_cancel(true);
                    }
                }
            }
  7. 4513861F-C564-42D2-BC9F-5FAED19E993E
    4513861F-C564-42D2-BC9F-5FAED19E993E avatar
    4090 posts
    Member since:
    Apr 2022

    Posted 24 Feb 2015 Link to this post

    Hello Jan,

    I'm glad the suggested approach has proven helpful.
    Thank you for sharing your specific solution with our community.

    Regards,
    Eyup
    Telerik
     
    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 Feedback Portal and vote to affect the priority of the items
     
Back to Top

This Code Library is part of the product documentation and subject to the respective product license agreement.