【问题标题】:How to Get the Row Index of a Kendo TreeList Custom createChild Command如何获取 Kendo TreeList 自定义 createChild 命令的行索引
【发布时间】:2016-08-31 05:05:47
【问题描述】:

我有一个具有以下自定义命令的 Kendo TreeList:

{
    command: [
        {
            name: "Edit",
            imageClass: "fa fa-pencil"
        },
        {
            name: "Delete",
            imageClass: "fa fa-trash"
        },
        {
            name: "createChild",
            imageClass: "fa fa-plus"
        }
    ], title: "Actions", width: "300px"
}

我点击创建子按钮,输入我的数据并点击“更新”。这将我带到我的 Kendo 数据源的“创建”定义:

create: function (e) {//Called when the create child command is saved
    //Collect the data needed for the save
}

此时我需要获取新行的行索引,但我似乎找不到正确的方法。我试过这样的事情:

$(e.target).closest("tr").parent().index()

但这给出了-1

还有:

var selectedRow = $scope.treelist.select();
var node = $scope.treelist.dataItem(selectedRow);

但节点未定义

有什么想法吗?

【问题讨论】:

    标签: kendo-ui kendo-grid kendo-treelist


    【解决方案1】:

    事实上,您没有将行引用到create 事件的范围内。但是,您可以在小部件的 DOM 中找到该元素:

    var index = $($("#grid").data("kendoTreeList").element).find(".k-grid-edit-row").index();
    

    活动编辑行接收k-grid-edit-row 类,您可以在小部件的 DOM 树中轻松找到它。

    Working Demo.

    不确定这是否是你真正想要的。

    【讨论】:

    • 这似乎正是我所需要的。谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-11-22
    • 2018-07-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-09
    • 1970-01-01
    相关资源
    最近更新 更多