JavaScript how do I refresh a HierarchicalDataSource for a Kendo TreeView?

TreeView creation:

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

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

    function treeviewSelect(e)
    {
        var node = this.dataItem(e.node);
        window.open(node.NotificationLink, "_self");
    }
}

Where things get updated and I need to refresh the dataSet:

$('#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.');
                        //Here is where I try to refresh the data source.
                        CreateNotificationTree(userId);
                    },
                    failure: function()
                    {
                        alert('Delete failed.');
                    }
                });
            treeView.remove($(this).closest('.k-item'));
        }
    });
});

The problem here is that it does refresh the tree view.... BUT NOT the CHILDREN nodes...

anyone know how to get this working?

Answer:1

I created a small api to generate test data on the fly. Each call creates a fresh user and returns the created data. To load the data I use the package request: var flow = protractor.promise....

I created a small api to generate test data on the fly. Each call creates a fresh user and returns the created data. To load the data I use the package request: var flow = protractor.promise....

I want to display a jQuery UI tabs inside a Dialog but it shows up Directory Listing of my asp.net app for no reason. It also changes the css of my page. What's going on here? Javascript: $("#...

I want to display a jQuery UI tabs inside a Dialog but it shows up Directory Listing of my asp.net app for no reason. It also changes the css of my page. What's going on here? Javascript: $("#...

I am trying to get some event listeners to work, but for some reason they are not working properly. The two event blocks below work fine on their own, but together only the removes block works. If I ...

I am trying to get some event listeners to work, but for some reason they are not working properly. The two event blocks below work fine on their own, but together only the removes block works. If I ...

  1. getelementsbyclassname doesn't work
  2. getelementsbyclassname doesn't work in ie
  3. document.getelementsbyclassname doesn't work
  4. javascript getelementsbyclassname doesn't work
  5. getelementsbyclassname object doesn't support this property

I have a situation which is best described using the following code: Meteor.publish('users', function (name) { return Users.find({name: name}); }); Meteor.publish('posts', function (userId) { ...

I have a situation which is best described using the following code: Meteor.publish('users', function (name) { return Users.find({name: name}); }); Meteor.publish('posts', function (userId) { ...

  1. meteor iron router
  2. meteor iron router tutorial
  3. meteor iron router redirect
  4. meteor iron router example
  5. meteor iron router import
  6. meteor iron router login
  7. meteor add iron router
  8. meteor install iron router
  9. meteor js iron router
  10. meteor use iron-router