【问题标题】:Kendo Grid Drag & Drop Destination is undefined剑道网格拖放目标未定义
【发布时间】:2014-09-30 13:03:38
【问题描述】:

我正在使用此参考 www.jsfiddle.net/JBeQn/ 实现剑道网格拖放功能

一切正常,但是当我进行拖放和放置事件时,我收到 dest is undefined 错误,我不确定为什么会发生这种情况,我使用的是最新版本的 kendo 和 jQuery。

grid.table.kendoDropTarget({
group: "gridGroup",
drop: function(e) {        
    e.draggable.hint.hide();
    var target = dataSource.getByUid($(e.draggable.currentTarget).data("uid")),
        dest = $(document.elementFromPoint(e.clientX, e.clientY));

    if (dest.is("th")) {
        return;
    }       
    dest = dataSource.getByUid(dest.parent().data("uid"));

    //not on same item
    if (target.get("id") !== dest.get("id")) {
        //reorder the items
        var tmp = target.get("position");
        target.set("position", dest.get("position"));
        dest.set("position", tmp);

        dataSource.sort({ field: "position", dir: "asc" });
    }                
}

});

任何帮助将不胜感激

【问题讨论】:

    标签: jquery kendo-ui drag-and-drop kendo-grid


    【解决方案1】:

    dest 为空,因为 getByUid 方法需要唯一的由 kendo 网格动态创建的 data-uid。

    你可以看到代码

    dest.parent()
    

    确保 dest.parent 应该到达 tr 元素,进一步 dest.parent().data("uid") 将从 tr 读取 UID

    希望这对其他人有所帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-09-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-21
      • 1970-01-01
      相关资源
      最近更新 更多