0

これは機能的なスタートですが、最後の部分を取得できません...

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);
                    }
                }

            }

誰かが私にこれを手伝ってもらえますか?

4

1 に答える 1

0

私はそれを行う方法を考え出しました:

$('#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'));
        }
    });
});
于 2013-08-07T00:12:43.050 に答える