How to fire the updateedited method from an outside button.

20 posts, 0 answers
  1. Stephen
    Stephen avatar
    2 posts
    Member since:
    Mar 2012

    Posted 10 Oct 2013 Link to this post

    Hello, I am using a RadGrid to do some batch updating.  My question is..how do you get the grid to commit updates from an outside button.  In other words I want the user to enter in some data and then fill out other areas of the form and then hit submit.  That's when the action of updating will occur.

    Thanks in advance.
  2. Eyup
    Admin
    Eyup avatar
    3009 posts

    Posted 15 Oct 2013 Link to this post

    Hi Stephen,

    You can use the following approach to achieve the requested functionality:
    grid.get_batchEditingManager().saveChanges(grid.get_masterTableView());

    Hope this helps. Please give it a try and let me know if it works for you.

    Regards,
    Eyup
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Stephen
    Stephen avatar
    2 posts
    Member since:
    Mar 2012

    Posted 15 Oct 2013 Link to this post

    Hello and thanks for the reply.

    I don't know where the method get_batchEditingManager() can be found.  Are you talking about using a new instance of the grid.
    RadGrid grid = (this.FindControl("gridItems") as RadGrid);

    and then saying
    grid.get_batchEditingManager().saveChanges(grid.get_masterTableView());

    If that is the case then get_batchEditingManager() is not correct.

    Thanks,
    Steve
  5. Eyup
    Admin
    Eyup avatar
    3009 posts

    Posted 18 Oct 2013 Link to this post

    Hi Stephen,

    Here is a basic sample demonstrating how the suggested method can be used on a button click:
    <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="initSaveAllCommand(); return false;" />
    JavaScript:
    function initSaveAllCommand(sender, args) {
        var grid = $find("<%= RadGrid1.ClientID %>");
        grid.get_batchEditingManager().saveChanges(grid.get_masterTableView());
    }

    That should do the trick.

    Regards,
    Eyup
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  6. Vinomanoharan
    Vinomanoharan avatar
    4 posts
    Member since:
    Sep 2013

    Posted 21 Oct 2013 Link to this post

    Hi,

    The code you have given works well in all the browsers other than IE 9,

    Do you have any fix or work around for it. 

    $('.SS').each(function () {
                   var gridID = $(this).attr('value');
                   var grid = $find(gridID);
                   grid.get_batchEditingManager().saveChanges(grid.get_masterTableView()); //this line does not work in IE9
               });

    Since the above code is not working in IE9, the save changes method is not getting triggered.

    Thanks
    Vino
  7. Eyup
    Admin
    Eyup avatar
    3009 posts

    Posted 24 Oct 2013 Link to this post

    Hello Vino,

    On my side the suggested approach works correctly on all browsers. Can you please run the attached web site and let us know if it works as expected from your end, too?

    Regards,
    Eyup
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  8. Vinomanoharan
    Vinomanoharan avatar
    4 posts
    Member since:
    Sep 2013

    Posted 24 Oct 2013 Link to this post

    Hi, 

    Yes the suggested approach will work for a page containing one grid. But when we have a screen where more than one Grid with batch edit mode, the problem starts here.

    I am calling the save change for each grid one by one in javascript. But only the first grid is getting saved.

    Thanks
    Vino
  9. Eyup
    Admin
    Eyup avatar
    3009 posts

    Posted 29 Oct 2013 Link to this post

    Hi Vino,

    You can use the new saveTableChanges method to achieve the requested simultaneous updating operation:
    http://www.telerik.com/help/aspnet-ajax/grid-batch-editing.html

    Hope this helps.

    Regards,
    Eyup
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  10. Troy
    Troy avatar
    11 posts
    Member since:
    Aug 2012

    Posted 27 Dec 2013 Link to this post

    I noticed that the initSaveAllCommand();  wont fire if I use a RadButton instead of a normal ASP button.

    Why?
  11. Eyup
    Admin
    Eyup avatar
    3009 posts

    Posted 30 Dec 2013 Link to this post

    Hi Troy,

    I am glad that you have managed to find the answer by yourself as stated in the following thread:
    http://www.telerik.com/community/forums/aspnet-ajax/grid/default-empty-grid-to-insert-mode-on-form-load.aspx

    I suggest that we continue our conversation in the mentioned thread to enable other developers with similar issues to track the discussion more easily.

    Regards,
    Eyup
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  12. Lydia
    Lydia avatar
    7 posts
    Member since:
    Dec 2013

    Posted 13 Mar 2014 in reply to Eyup Link to this post

    Hi, I have same issue with Vinomanoharan, the code didnt work on IE9, how to resolve this?
    grid.get_batchEditingManager().saveChanges(grid.get_masterTableView()); //this line does not work in IE9

    Thanks.
  13. Lydia
    Lydia avatar
    7 posts
    Member since:
    Dec 2013

    Posted 13 Mar 2014 in reply to Lydia Link to this post

    Hi found the issue, it's because i added __doPostBack(obj.id,''); after the grid.get_batchEditingManager().saveChanges(grid.get_masterTableView()); so that's why the save changes didnt work.
    Thanks.
  14. Austin
    Austin avatar
    13 posts
    Member since:
    Apr 2009

    Posted 01 Dec 2014 Link to this post

    If I have a RadGrid in BatchEdit mode, and I need to save the changes from an outside button, then how do I accomplish the original function assigned to the button in the first place?  I have a 'Save' method that is originally assigned to the button click and causes a postback which saves other UI values on the screen outside of the RadGrid.  But now it seems I have to choose between saving the contents of the RadGrid via the javascript call to saveChanges and canceling the postback of my button, OR allowing the postback to happen but then not getting the saveChanges to fire.  Am I missing something here?

    <asp:Button ID="btnSave" runat="server" Text="Save" CausesValidation="true" ToolTip="Save Data" OnClick="btnSave_Click" OnClientClick="initSaveAllCommand(); return false;"/>

  15. Eyup
    Admin
    Eyup avatar
    3009 posts

    Posted 04 Dec 2014 Link to this post

    Hi Austin,

    You can use the following event handler to achieve the requested functionality:
    protected void RadGrid1_BatchEditCommand(object sender, GridBatchEditingEventArgs e)
    {
        SaveExternalControls();
    }

    For additional details, you can check the following article:
    http://www.telerik.com/help/aspnet-ajax/grid-batch-editing.html

    Hope this helps.

    Regards,
    Eyup
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  16. Hieu
    Hieu avatar
    1 posts
    Member since:
    Mar 2014

    Posted 14 Aug 2015 in reply to Eyup Link to this post

    Hi Admin,

     I've used this grid.get_batchEditingManager().saveChanges(grid.get_masterTableView()); to submit request to server.

    Everything looks good in Chrome and Firefox but it's not working on IE.

    Please help advise.

     

    Thanks,

    Hieu

  17. Eyup
    Admin
    Eyup avatar
    3009 posts

    Posted 18 Aug 2015 Link to this post

    Hi Hieu,

    Please make sure that you are using the latest release version:
    http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/batch-editing/defaultcs.aspx

    If the issue remains, you can open a formal support ticket and elaborate on your specific scenario.

    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
  18. David
    David avatar
    1 posts
    Member since:
    Dec 2012

    Posted 15 Sep 2015 in reply to Eyup Link to this post

    What if there are multiple RadGrids on the page?  I do not want to process the SaveExternalControls() multiple times (1 for each RadGrid).  Assuming there are 2 grids, I want to process the data from both grids and after that, do a one time save (to the datasource).

    Eyup said:Hi Austin,


    protected void RadGrid1_BatchEditCommand(object sender, GridBatchEditingEventArgs e)
    {
        SaveExternalControls();
    }

  19. Eyup
    Admin
    Eyup avatar
    3009 posts

    Posted 17 Sep 2015 Link to this post

    Hi David,

    You can try to pass multiple tableview objects to the saveTableChanges(tableViews) method to achieve this requirement:
    http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/data-editing/edit-mode/batch-editing#client-side-gridbatchediting-api

    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
  20. Emad
    Emad avatar
    16 posts
    Member since:
    Dec 2015

    Posted 05 Mar in reply to Eyup Link to this post

    Hi,

    I'm using external button to save two radgrids in batch edit mode. It's working fine with below code.

    I have only one issue, if one grid have required validation fires.

    below code still work !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

     

    function saveTowGrids() {
                try{
                    var grid1 = $find("<%= RadGrid1.ClientID %>");
                    var masterTable1 = grid1.get_masterTableView();
                    var grid2 = $find("<%= RadGrid2.ClientID %>");
                    var masterTable2 = grid2.get_masterTableView();
                    var batchEditManager = grid2.get_batchEditingManager();
                    var tables = [];
                    tables.push(masterTable1);
                    tables.push(masterTable2);
                    batchEditManager.saveTableChanges(tables);
                    alert("save completed");
                } catch (e) { alert(e);}
            }

  21. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1796 posts

    Posted 08 Mar Link to this post

    Hello Emad,

    For others convenience, I am pasting the answer from the answer from the other forum thread, where you have asked the same question:

    "You could use the BatchEditingManager and see if there is open row or cell for editing and initiate the saving only if no cell/row is opened:
    <telerik:RadCodeBlock runat="server">
        <script>
            function saveGrid(sender, args) {
                var grid = $find("<%= RadGrid1.ClientID%>");
                var tableView = grid.get_masterTableView();
                var batchManager = grid.get_batchEditingManager();
                if (batchManager.get_currentlyEditedRow() || batchManager.get_currentlyEditedCell()) {
                    alert("pending editing");
                }
                else {
                    alert("could initiate save");
                    //initate the save through the BatchEditingManager
                }
            }
        </script>
    </telerik:RadCodeBlock>


    Kind Regards,
    Konstantin Dikov
    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
UI for ASP.NET Ajax is Ready for VS 2017