How to disable a draggable row event on a grid

2 posts, 0 answers
  1. Bob
    Bob avatar
    4 posts
    Member since:
    Sep 2013

    Posted 04 Nov 2014 Link to this post

    I have a Kendo Grid with some "kendoDraggable()" methods on it. This allows me to drag/drop the rows (i.e. reordering rows).

    It's based on this :

    The drag/drop of the rows works great, but it then almost completely disables the Edit/Update functions on the grid. That is, the Edit is buggy and won't let me access the cell's text content.

    In my attached screen shots, I show the portion of the grid I'm trying to edit. I can click on the EDIT/UPDATE buttons, but CANNOT access the text. There's no error whatsoever.

    How can I safely disable the kendoDraggable() events ?

    I've tried this, but it doesn't work :

    $('#userKriGrid tbody tr').off("click", '**');

    and neither does this :


    HTML def:

    <span id="userKriGrid" 

    and here's the function in my angular controller :

    function addDragDropKRIGridRow() {
                var mainGrid = $("#userKriGrid").data("kendoGrid");
                var mainDataSource = vm.kriUserGridDS;
                var selectedClass = 'k-state-selected';
                $.fn.reverse = [].reverse;  //save a new function from Array.reverse
                $(document).on('click', '#userKriGrid tbody tr', function (e) {
                    if (e.ctrlKey || e.metaKey) {
                    } else {
                    filter: "tbody tr",
                    group: "gridGroup",
                    axis: "y",
                    hint: function (item) {
                        var helper = $('<div class="k-grid k-widget drag-helper"/>');
                        if (!item.hasClass(selectedClass)) {
                        var elements = item.parent().children('.' + selectedClass).clone();
              'multidrag', elements).siblings('.' + selectedClass).remove();
                        return helper.append(elements);
                    group: "gridGroup",
                    drop: function (e) {
                        var draggedRows = e.draggable.hint.find("tr");
                        var dropLocation = $(document.elementFromPoint(e.clientX, e.clientY)),
                            dropGridRecord = mainDataSource.getByUid(dropLocation.parent().attr("data-uid"))
                        if ("th")) {
                        var beginningRangePosition = mainDataSource.indexOf(dropGridRecord),//beginning of the range of dropped row(s)
                            rangeLimit = mainDataSource.indexOf(mainDataSource.getByUid(draggedRows.first().attr("data-uid")));//start of the range of where the rows were dragged from
                        //if dragging up, get the end of the range instead of the start
                        if (rangeLimit > beginningRangePosition) {
                            draggedRows.reverse();//reverse the records so that as they are being placed, they come out in the correct order
                        //assign new spot in the main grid to each dragged row
                        draggedRows.each(function () {
                            var thisUid = $(this).attr("data-uid"),
                                itemToMove = mainDataSource.getByUid(thisUid);
                            mainDataSource.insert(beginningRangePosition, itemToMove);
                        //set the main grid moved rows to be dirty
                        draggedRows.each(function () {
                            var thisUid = $(this).attr("data-uid");
                            mainDataSource.getByUid(thisUid).set("dirty", true);
                        //remark things as visibly dirty
                        var dirtyItems = $.grep(mainDataSource.view(), function (e) { return e.dirty === true; });
                        for (var a = 0; a < dirtyItems.length; a++) {
                            var thisItem = dirtyItems[a];
                            mainGrid.tbody.find("tr[data-uid='" + thisItem.get("uid") + "']").find("td:eq(0)").addClass("k-dirty-cell");
                            mainGrid.tbody.find("tr[data-uid='" + thisItem.get("uid") + "']").find("td:eq(0)").prepend('<span class="k-dirty"></span>')

  2. Alexander Valchev
    Alexander Valchev avatar
    2887 posts

    Posted 06 Nov 2014 Link to this post

    Hi Bob,

    I already replied in the support thread that you submitted on the same subject. For convenience I will paste my reply here as well.

    The example you referenced is outdated. In latter Kendo UI releases we introduced a Sortable widget which can be used to reorder Grid rows using drag and drop. For more information please check this demo and this help topic. In order to resolve the editing issues you should use a more specific filter selector that excludes the item that is currently in edit mode. For example .filter(">tbody >tr:not(.k-grid-edit-row)". In this way the Sortable functionality will not interfere with Grid's editing feature.

    In case you prefer using the current approach you may exclude the editor inputs using the ignore option of the Draggable.
    I hope this information will help.

    Alexander Valchev
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top