This is a migrated thread and some comments may be shown as answers.

Force reload of child nodes

2 Answers 1282 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Steven
Top achievements
Rank 1
Steven asked on 28 Jun 2013, 05:25 AM
Is there a client-side method to force a tree node to clear and then re-load (or refresh) all child nodes?  I am dynamically loading a tree view and it's child nodes via AJAX.  When I add a node, I call another AJAX method to add the node to my database.  I would like the treeview/node to then refresh itself and automatically call the dataSource.read method for the node.

Thank you.

*** EDIT ***

I have found a solution that mostly works:

        var treeView = $('#catalogTreeView').data('kendoTreeView');
        var selectedNode = treeView.select();
        var selectedDataItem = treeView.dataItem(selectedNode);

                    treeView.collapse(selectedNode);
                    selectedDataItem.loaded(false);
                    treeView.expand(selectedNode);

However, the expand does not always work and the node stays collapsed.  Is this the correct way to do this, or is there a preferred method?

2 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 01 Jul 2013, 03:35 PM
Hello,

You can use the node load method to make a request for the children:

selectedDataItem.loaded(false);
selectedDataItem.load();
Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Steven
Top achievements
Rank 1
answered on 01 Jul 2013, 08:01 PM
That worked perfectly, thank you!
Tags
TreeView
Asked by
Steven
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Steven
Top achievements
Rank 1
Share this question
or