javascript - 如何从 Kendo TreeView 中删除选中的节点?

标签 javascript jquery kendo-treeview

这是我的配置:

$(function()
{
    var data = new kendo.data.HierarchicalDataSource({
        transport: {
            read: {
                url: "../api/notifications/byuserid/10078261",
                contentType: "application/json"
            }
        },
        schema: {
            model: {
                children: "notifications"
            }
        }
    });

    $("#treeview").kendoTreeView({
        dataSource: data,
        loadOnDemand: false,
        checkboxes: {
            checkChildren: true
        },
        dataTextField: ["notificationType", "NotificationDesc"]
    });
});

在“删除”按钮的单击事件中,我想删除所有选中的节点。

$(document).ready(function()
{
    $('#btnDelete').click(function()
    {
        var treeView = $('#treeview').data("kendoTreeView");
        var selectedNodes = treeView.select();
        //here's where im not sure what to do...
    });
});

Treeview 位于标记中(我知道一团糟......我现在正在解决所有这些困惑):

<body onload=" Resize(); ">
   <form id="frmTake2Home" runat="server">
       <table class="main" style="border-style: hidden; padding: 0px">
          <td class="tbody">
             <table style="border-spacing: 0px; border-style: hidden; padding: 0px; vertical-align: top" width="100%" border="0">
              <tr>
                <td id="tdTreeView" valign="top" width="48%">
                <tr>
                  <td colspan="2">
                    <div id="treeview"></div> //here's my kendo treeview

最佳答案

更新

$(document).ready(function(){

    var treeView = $('#treeview').data("kendoTreeView");             

    $('#btnDelete').on('click', function(){
        $('#treeview').find('input:checkbox:checked').each(function(){
            treeView.remove($(this).closest('.k-item'));
        });
    });

});

关于javascript - 如何从 Kendo TreeView 中删除选中的节点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17978101/

相关文章:

css - 在 Kendo 网格上创建拖动提示的最佳方式

javascript - Chrome App webview 和触摸滚动传播

javascript - Bootstrap : how to make scrollable list with fixed height in percents

javascript - 谷歌地图 - 欺骗计算机将单击视为双击

javascript - 调用 Facebook 的 BigPipe onPageletArrive 脚本

kendo-ui - 使用模板自定义 Kendo Treeview 的问题

css - 如何将以下 CSS 仅应用于 Kendo Treeview 的父节点?

javascript - 在页面加载时检查 md-radio-group

javascript - 如何在jquery colorbox中自定义#cboxLoadedContent的宽度

javascript - 使用 Javascript 从具有属性选择器的 CSS 类更改属性的状态