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

listen to cancel changes button event - toolbar

9 Answers 887 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Wit
Top achievements
Rank 1
Wit asked on 07 Oct 2014, 02:38 PM
I have a grid with batch editing
toolbar: ["cancel"]  creates 'cancel changes' button like in the demo : http://demos.telerik.com/kendo-ui/grid/editing

how  could I listen to that event? I would like to perform some additional clean up actions

grid.cancel seems to only be working when I press ESC in edit mode

9 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 08 Oct 2014, 11:54 AM
Hello Witek,


Indeed the cancel event of the Grid is not fired in that case. If you would like to execute some additional logic, you could bind to the mousedown event of the button itself.
E.g.
$("#Grid").on("mousedown", ".k-grid-cancel-changes", function (e) {
    //custom logic
});

Regards,
Dimiter Madjarov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Wit
Top achievements
Rank 1
answered on 09 Oct 2014, 03:08 PM
Hi Dimiter,

Would you have any suggestions how I could create a custom directive in angularjs to add that functionality to kedno grid?

Thank you
0
Wit
Top achievements
Rank 1
answered on 10 Oct 2014, 08:16 AM
I am not sure if I am going in the right direction but that is where I am at the moment (it is not working)

angular.module('myApp')
        .directive('kendo.ui.Grid', function () {
               return {
                restrict: 'A',
                scope: {
                    onCancelChanges: "&"
                },
                controller: function ($scope, $element, $attrs, $location) {
                    $($element).on("mousedown", ".k-grid-cancel-changes", function () {
                        $scope.onCancelChanges();
                    });
                }
            }
});
0
Accepted
Dimiter Madjarov
Telerik team
answered on 13 Oct 2014, 11:02 AM
Hello Witek,


You could restrict the element by class name and attach the click handler using the link() method. Here is a runnable example, which demonstrates this.

Regards,
Dimiter Madjarov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Wit
Top achievements
Rank 1
answered on 13 Oct 2014, 11:15 AM
Thank you
0
Ezequiel
Top achievements
Rank 2
answered on 04 Nov 2015, 03:58 PM

Hi Dimiter,

 [quote]Dimiter Madjarov said:
$("#Grid").on("mousedown", ".k-grid-cancel-changes", function (e) {
    //custom logic
});
[/quote]

I have a detail grid in MVC (client detail template) , so, I will have n grids each one with different name.

How could I do this?

0
Dimiter Madjarov
Telerik team
answered on 06 Nov 2015, 07:59 AM

Hello Ezequiel,

You could use the same mousedown handler for the whole hierarchy. Are you experiencing any specific issues with it?

Regards,
Dimiter Madjarov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Ori
Top achievements
Rank 1
answered on 29 Jan 2016, 02:35 PM
The question is - why is it not firing the cancel event when it does basically the same?
0
Dimiter Madjarov
Telerik team
answered on 29 Jan 2016, 02:54 PM

Hello,

The current behavior is by design, the cancel event is fired only in inline/popup edit mode, when the cancel button is clicked.

Regards,
Dimiter Madjarov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Wit
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Wit
Top achievements
Rank 1
Ezequiel
Top achievements
Rank 2
Ori
Top achievements
Rank 1
Share this question
or