Matt
Matt

Reputation: 2863

KendoUI Grid Handle click events for Column Headers

Im wanting to hook up a mouse down (both left and right click) event on the click of the grid column headers in a KendoUI grid object. Just wondering if anyone has any ideas on how to go about this?

Upvotes: 1

Views: 2987

Answers (1)

ezanker
ezanker

Reputation: 24738

You could use the mousedown event:

  $(document).on("mousedown", " .k-header", function(e){
       var fieldname = $(this).data("field");
       switch (e.which) {
            case 1:
                alert('Left Mouse button pressed. Field = ' + fieldname);
                break;
            case 2:
                alert('Middle Mouse button pressed. Field = ' + fieldname);
                break;
            case 3:
                alert('Right Mouse button pressed. Field = ' + fieldname);
                break;
        }

  });

The kendo ui grid assigns a class of k-header to the header cells and the field name is stored in a data-attribute (data-field="").

DEMO

Upvotes: 2

Related Questions