if save changes is never invoked client side, can we get the changes made to a batch edit radgrid server side? we'd like to eliminate the need to click 'save changes' and have the whole form (grid and non grid fields) submitted by a single action.
4 Answers, 1 is accepted
0
Mitch
Top achievements
Rank 1
answered on 18 Nov 2014, 05:51 PM
if i call savechanges thru javascript automatically on submit, is there some way to ensure it executes first?
$(document).ready(function () {
// do radgrid save on form submit
var originalSubmit = document.forms[0].onsubmit;
document.forms[0].onsubmit = function () { SaveChangesInGrid(); onsubmit; }
});
function SaveChangesInGrid(sender, args) {
$find('<%=rgAffectedOther.ClientID%>').get_batchEditingManager().saveChanges(grid.get_masterTableView());
}
$(document).ready(function () {
// do radgrid save on form submit
var originalSubmit = document.forms[0].onsubmit;
document.forms[0].onsubmit = function () { SaveChangesInGrid(); onsubmit; }
});
function SaveChangesInGrid(sender, args) {
$find('<%=rgAffectedOther.ClientID%>').get_batchEditingManager().saveChanges(grid.get_masterTableView());
}
0
Hello Mitch,
Actually you may experience problems when following this approach. If the postback does not get initiated by the batch editing manager the user changes will not be sent to the server. That said I would recommend calling the saveChanges method when a button is clicked thus transferring the grid changes the server. Later you can access them inside the OnBatchEditCommand handler alongside with the other form elements values.
Regards,
Angel Petrov
Telerik
Actually you may experience problems when following this approach. If the postback does not get initiated by the batch editing manager the user changes will not be sent to the server. That said I would recommend calling the saveChanges method when a button is clicked thus transferring the grid changes the server. Later you can access them inside the OnBatchEditCommand handler alongside with the other form elements values.
Regards,
Angel Petrov
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
Mitch
Top achievements
Rank 1
answered on 20 Nov 2014, 03:27 PM
is there any way to ensure a call to savechanges finishes before the form is allowed to submit? it seems when I call savechanges immediately before form submit, it sometimes executes first and sometimes second.
0
Hello Mitch,
In order to ensure that the saveChanges method gets called I would recommend modifying the logic so that the button which triggers the postback calls the method.
ASPX:
By following the above approach you should be able to make things work as expected.
Regards,
Angel Petrov
Telerik
In order to ensure that the saveChanges method gets called I would recommend modifying the logic so that the button which triggers the postback calls the method.
ASPX:
<
script
>
function SaveChanges() {
var grid = $find('<%=rgAffectedOther.ClientID%>');
grid.get_batchEditingManager().saveChanges(grid.get_masterTableView());
}
</
script
>
<
asp:Button
Text
=
"Save Changes"
OnClientClick
=
"SaveChanges(); return false;"
runat
=
"server"
/>
Regards,
Angel Petrov
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.