Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kendo UI Grid Disable Drag Row Selecting

Currently I have a Kendo Grid with multi selectable rows. My Problem is i cannot select text from any columns because of the Drag Row Selecting feature of Kendo. is there Any way to disable the Drag Row Selecting in Kendo Grid?

Thank you very much

like image 956
Emesti Avatar asked Nov 12 '22 10:11

Emesti


1 Answers

I know this is an old question, but the best answer I could find to this problem was over on the telerik forums

I adapted an angular version of the solution, which additionally calls the grids change callback.

.directive('kendoGrid', ['$', '$parse',
  function($parse) {
    return {
      link: function(scope, element, attrs) {
        if (attrs.multiselect !== undefined) {
          attrs.kSelectable = '""';
          var selectedClass = 'k-state-selected';
          var fn = $parse(attrs.kOnChange);
          $(element).delegate('tbody tr', 'click', function(e) {
            e.preventDefault();
            if (e.ctrlKey || e.metaKey) {
              $(this).toggleClass(selectedClass);
            } else {
              $(this).addClass(selectedClass).siblings().removeClass(selectedClass);
            }
            var grid = $(element).data('kendoGrid');
            if (fn) {
              scope.$apply(function() {
                fn(scope, {
                  kendoEvent: {
                    sender: grid
                  }
                });
              });
            }
          });
          scope.$on(
            '$destroy',
            function() {
              $(element).undelegate('tbody tr', 'click');
            }
          );
        }
      }
    };
  }
])

As per the comment on the forum, the traditional grid.select() call no longer works as it requires a selection model.

var grid = kendoEvent.sender;
var selectedRows = grid.tbody.find(".k-state-selected"); //grid.select();
like image 165
Josh Leeming Avatar answered Dec 15 '22 19:12

Josh Leeming