http://www.telerik.com/support/code-library/prevent-losing-batch-editing-changes-on-paging-or-any-other-postback
Where do I set to ignore the [Save changes] button that will be doing the update? I get the same prompt that changes will be lost.
Where do I set to ignore the [Save changes] button that will be doing the update? I get the same prompt that changes will be lost.
7 Answers, 1 is accepted
0
Lenny_shp
Top achievements
Rank 2
answered on 11 Sep 2014, 08:12 PM
How do I skip [Save changes] button from batch Edit to trigger cancel prompt?
// Prevents other RadGrid commands
functionLibrary.gridCommand = function (sender, args) {
if (changesString.length > 0 && !confirmationHandled) {
confirmationHandled = confirm(message);
args.set_cancel(!confirmationHandled);
}
}
// Prevents other RadGrid commands
functionLibrary.gridCommand = function (sender, args) {
if (changesString.length > 0 && !confirmationHandled) {
confirmationHandled = confirm(message);
args.set_cancel(!confirmationHandled);
}
}
0
Hello Lenny,
The latest 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
Hope this helps.
Regards,
Eyup
Telerik
The latest 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
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
Lenny_shp
Top achievements
Rank 2
answered on 16 Sep 2014, 01:30 PM
Thanks, the sample code for OnUserAction doesn't prompt for these actions that would lose the changes:
1. Closing browser
2. Clicking on Refresh button
How can I add those two actions to the prompt?
1. Closing browser
2. Clicking on Refresh button
How can I add those two actions to the prompt?
0
Lenny_shp
Top achievements
Rank 2
answered on 17 Sep 2014, 09:20 PM
I switched from OnUserAction to OnCommand to capture the [Refresh] button and custom filter.
I guess there is no easy way to incorporate the browser exit warning via this method.
<ClientEvents OnCommand="CheckChanges" />
function CheckChanges(sender, args) {
if (sender.get_batchEditingManager().hasChanges(sender.get_masterTableView()) && (args.get_commandName() != "BatchEdit") &&
!confirm("Unsaved changes will be lost. Proceed?")) {
args.set_cancel(true);
}
}
I guess there is no easy way to incorporate the browser exit warning via this method.
<ClientEvents OnCommand="CheckChanges" />
function CheckChanges(sender, args) {
if (sender.get_batchEditingManager().hasChanges(sender.get_masterTableView()) && (args.get_commandName() != "BatchEdit") &&
!confirm("Unsaved changes will be lost. Proceed?")) {
args.set_cancel(true);
}
}
0
Hi Lenny,
You can check the sample mentioned in your first post to implement browser preventing:
Here you can remove the confirmationHandled condition and get changesString from some global variable which holds the Batch changes.
That should do the trick.
Regards,
Eyup
Telerik
You can check the sample mentioned in your first post to implement browser preventing:
// Prevents closing the browser or navigating from the page
window.onbeforeunload =
function
() {
if
(!confirmationHandled && changesString.length > 0) {
return
message;
}
else
{
confirmationHandled =
false
;
}
}
Here you can remove the confirmationHandled condition and get changesString from some global variable which holds the Batch changes.
That should do the trick.
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
Lenny_shp
Top achievements
Rank 2
answered on 22 Sep 2014, 02:46 PM
How do I suppress BatchEdit button from kicking off onbeforeunload? onRequestStart fires first then onbeforeunload.
(args.get_commandName() != "BatchEdit")
(args.get_commandName() != "BatchEdit")
window.onbeforeunload = function () {
var grid = $find("<%=RadGrid1.ClientID %>");
if (grid.get_batchEditingManager().hasChanges(grid.get_masterTableView())) {
return "Unsaved changes will be lost. Proceed?";
}
}
0
Hi Lenny,
For your convenience I have prepared a sample project where the functionality is implemented. Give it a try and let me know how it works for you.
Regards,
Viktor Tachev
Telerik
For your convenience I have prepared a sample project where the functionality is implemented. Give it a try and let me know how it works for you.
Regards,
Viktor Tachev
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.