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

How to fire the updateedited method from an outside button.

20 Answers 926 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Stephen
Top achievements
Rank 1
Stephen asked on 10 Oct 2013, 07:45 PM
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.

20 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 15 Oct 2013, 08:23 AM
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.
0
Stephen
Top achievements
Rank 1
answered on 15 Oct 2013, 01:14 PM
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
0
Eyup
Telerik team
answered on 18 Oct 2013, 07:00 AM
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.
0
Vinomanoharan
Top achievements
Rank 1
answered on 21 Oct 2013, 07:21 AM
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
0
Eyup
Telerik team
answered on 24 Oct 2013, 06:33 AM
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.
0
Vinomanoharan
Top achievements
Rank 1
answered on 24 Oct 2013, 11:53 AM
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
0
Eyup
Telerik team
answered on 29 Oct 2013, 02:44 PM
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.
0
Troy
Top achievements
Rank 1
answered on 28 Dec 2013, 05:37 AM
I noticed that the initSaveAllCommand();  wont fire if I use a RadButton instead of a normal ASP button.

Why?
0
Eyup
Telerik team
answered on 30 Dec 2013, 12:55 PM
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.
0
Lydia
Top achievements
Rank 1
answered on 13 Mar 2014, 06:12 AM
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.
0
Lydia
Top achievements
Rank 1
answered on 13 Mar 2014, 09:44 AM
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.
0
Austin
Top achievements
Rank 1
answered on 01 Dec 2014, 09:50 AM
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;"/>

0
Eyup
Telerik team
answered on 04 Dec 2014, 08:27 AM
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.

 
0
Hieu
Top achievements
Rank 1
answered on 14 Aug 2015, 07:31 AM

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

0
Eyup
Telerik team
answered on 18 Aug 2015, 03:09 PM
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
0
David
Top achievements
Rank 1
answered on 15 Sep 2015, 07:35 PM

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).

[quote]Eyup said:Hi Austin,


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

[/quote]
0
Eyup
Telerik team
answered on 17 Sep 2015, 11:27 AM
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
0
Emad
Top achievements
Rank 1
answered on 05 Mar 2016, 09:16 AM

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);}
        }

0
Konstantin Dikov
Telerik team
answered on 08 Mar 2016, 07:54 AM
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
0
Austin
Top achievements
Rank 1
answered on 11 May 2017, 10:33 PM

Looking back over my old posts.  This is how I got my solution to work; i.e. using an external button to save multiple batch edit grids all at once AND saving all the UI on the page outside the grids as well:

        <%--//This triggers the save process on the server side for each RG on the page. --%>
        function initSaveAllCommand(sender, args) {

            if (Page_ClientValidate("")) {
                
                    var grid;
                    var tableViews = [];

                <%--//For each of the objects on the page with the CSS class 'RG' attached (which I attached to each rad grid)... --%>
                $('.RG').each(function () {
                    <%--//...Get the ID of the object (the rad grid) --%>
                        grid = $find($(this).attr('id'));
                    <%--//and then add a pointer to the 'master table view' into the 'table views' array to use below in 'save table changes' --%>
                        tableViews.push(grid.get_masterTableView());
                    });
                    <%-- I use this hidden input field to make note to call the 'save' logic from the page's post back --%>
                    hdfSaveIsNeeded.val('true');  

                <%--//We need to grab ANY ONE of the batch editing managers on the page and fire the 'saveTableChanges' from it. --%>
                rgGridOne.get_batchEditingManager().saveTableChanges(tableViews);               
            }
        }

Tags
Grid
Asked by
Stephen
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Stephen
Top achievements
Rank 1
Vinomanoharan
Top achievements
Rank 1
Troy
Top achievements
Rank 1
Lydia
Top achievements
Rank 1
Austin
Top achievements
Rank 1
Hieu
Top achievements
Rank 1
David
Top achievements
Rank 1
Emad
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or