简体   繁体   English

从 Treelist kendo 中删除行

[英]Remove row from Treelist kendo

I would like to remove row from Treelist after click in button.单击按钮后,我想从 Treelist 中删除行。 I bind function in event "click: remove".我在事件“单击:删除”中绑定函数。 Firstly , I choose a row and next try remove object from DataSource.首先,我选择一行,然后尝试从数据源中删除对象。 And this point is not correct.而这一点是不正确的。

remove: function () {
                    var that = this;
                    if (this.isGridSelected) {
                        var arr = [];
                        arr = this.selectedRow.toJSON();//this line show selected row

                        this.roleDataSourcePrzypisane.remove(this.arr);//I think this row is wrong ...Remove no work
                        console.log(this.roleDataSourcePrzypisane);


                        this.set("roleDataSourcePrzypisane", this.roleDataSourcePrzypisane);

                    } else {
                        iwInfo('Please choose row', 'warning');
                    }


                }
function removeRow(e) {
    var treelistCurrentInstance = $("#treelist").data("kendoTreeList");
    var currentRow = $(e).closest('tr');
    treelistCurrentInstance.removeRow(currentRow);
}

I have tried something similar, i'm taking reference of current row by instance of button and using removeRow method of kendo treelist.我尝试过类似的方法,我通过按钮实例引用当前行并使用剑道树列表的 removeRow 方法。

Assume a button control:假设一个按钮控件:

<button id="btn">Remove selected row</button>

The click event removes a selected row in the kendoUI jQuery TreeList control:单击事件删除 kendoUI jQuery TreeList 控件中的选定行

$("#btn").click(function()
{
    let Treelist = $("#treelist").data("kendoTreeList");
    let Row = Treelist.select();
    Treelist.removeRow(Row);
});

Ensure that the TreeList is editable, eg with:确保 TreeList 是可编辑的,例如:

"editable": true

in the TreeList creation definition, otherwise the .removeRow() method won't work.在 TreeList 创建定义中,否则 .removeRow() 方法将不起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM