javascript - 你如何检查在Kendo TreeView中是否检查了父节点的 child ?

标签 javascript jquery kendo-treeview

这是一个功能性的开始,但我无法完成最后一部分......

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

    for (var i = 0; i < treeView.dataSource.view().length; i++)
    {
        if (treeView.dataSource.view()[i].checked)
        {
            if (treeView.dataSource.view()[i].hasChildren)
            {
                //this check is not working
                if (treeView.dataSource.view()[i].children.view()[i].checked)
                {
                    for (var j = 0; j < treeView.dataSource._data[i].notifications.length; j++)
                    {
                        notificationId = treeView.dataSource._data[i].notifications[j].ID;
                        alert('parent notification id: ' + notificationId);
                    }
                }

            }

有人可以帮我解决这个问题吗?

最佳答案

我想出了如何做到这一点:

$('#btnDelete').on('click', function()
{
    var treeView = $("#treeview").data("kendoTreeView");
    var userId = $('#user_id').val();

    $('#treeview').find('input:checkbox:checked').each(function()
    {
        debugger;
        var li = $(this).closest(".k-item")[0];
        var notificationId = treeView.dataSource.getByUid(li.getAttribute('data-uid')).ID;

        if (notificationId == "undefined")
        {
            alert('No ID was found for one or more notifications selected. These notifications will not be deleted. Please contact IT about this issue.');
        }
        else
        {
            $.ajax(
                {
                    url: '../api/notifications/deleteNotification?userId=' + userId + '&notificationId=' + notificationId,
                    type: 'DELETE',
                    success: function()
                    {
                        alert('Delete successful.');
                        CreateNotificationTree(userId);
                    },
                    failure: function()
                    {
                        alert('Delete failed.');
                    }
                });
            treeView.remove($(this).closest('.k-item'));
        }
    });
});

关于javascript - 你如何检查在Kendo TreeView中是否检查了父节点的 child ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18067148/

相关文章:

javascript - 如何为 Kendo UI TreeView 设置 Treeview 节点颜色?

javascript - AJAX 发布成功后如何调用 Kendo Treeview (服务器数据绑定(bind)类型)?

javascript - 更改模板后如何重新绑定(bind) Kendo ListView

javascript - 如何排序导致 nodejs - mongodb 搜索,但是,通过调用动态方法

javascript - MongoDB 索引 : String vs Int

Jquery ui 组合框(自动完成)消失

javascript - 如何使用 javascript 获取我的 css 元素的最大宽度

javascript - AngularJS 计数器计数到目标数

javascript - p5.j​​s 绘图功能如何工作?

javascript - 包含对象没有方法吗?