listen to cancel changes button event - toolbar

11 posts, 1 answers
  1. Wit
    Wit avatar
    43 posts
    Member since:
    Aug 2014

    Posted 07 Oct 2014 Link to this post

    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
  2. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2156 posts

    Posted 08 Oct 2014 Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
  4. Wit
    Wit avatar
    43 posts
    Member since:
    Aug 2014

    Posted 09 Oct 2014 Link to this post

    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
  5. Wit
    Wit avatar
    43 posts
    Member since:
    Aug 2014

    Posted 10 Oct 2014 in reply to Wit Link to this post

    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();
                        });
                    }
                }
    });
  6. Wit
    Wit avatar
    43 posts
    Member since:
    Aug 2014

    Posted 10 Oct 2014 in reply to Wit Link to this post

    my grid declaration looks like:
    <div kendo-grid="kgrid" oncancelchanges="test()" options="gridData"></div>
  7. Answer
    Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2156 posts

    Posted 13 Oct 2014 Link to this post

    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!
     
  8. Wit
    Wit avatar
    43 posts
    Member since:
    Aug 2014

    Posted 13 Oct 2014 in reply to Dimiter Madjarov Link to this post

    Thank you
  9. Ezequiel
    Ezequiel avatar
    36 posts
    Member since:
    Oct 2011

    Posted 04 Nov 2015 in reply to Dimiter Madjarov Link to this post

    Hi Dimiter,

     

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

    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?

  10. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2156 posts

    Posted 06 Nov 2015 Link to this post

    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!
     
  11. Ori
    Ori avatar
    10 posts
    Member since:
    Feb 2015

    Posted 29 Jan in reply to Dimiter Madjarov Link to this post

    The question is - why is it not firing the cancel event when it does basically the same?
  12. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2156 posts

    Posted 29 Jan Link to this post

    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!
     
Back to Top
Kendo UI is VS 2017 Ready