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

Problems selecting node - dataSource.read() not working

1 Answer 138 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Huw Lloyd
Top achievements
Rank 1
Huw Lloyd asked on 22 Nov 2013, 04:40 PM
Hi 

I have a treeview bound to a hierarchial data source from a database and use the requestEnd event to expand all nodes which works fine.

When I add a node via an ajax call it adds the data to the database correctly and I call dataSource.read()  to refresh the treeview as part of my ajax success function:
success: function () {
                      
                      foundItem = false;
                      $("#tree").data("kendoTreeView").dataSource.read();
                  }
 I then use the following code to find the item added (the unique name of which is stored in toSelectText) when the read function binds the tree, select it and display the details:
function onBound(e) {
            if (toSelectText != null && !foundItem) {
 
               var treeview = $("#tree").data("kendoTreeView");
               var selectitem = treeview.findByText(toSelectText);
 
               if (treeview.text(selectitem) == toSelectText) {
                   treeview.select(selectitem);
                   treeview.trigger("select", { node: selectitem });
                   foundItem = true;
               }
           }
 
       };
The foundItem variable is used because the call to this function is made many times as the read builds up the child data for each node.

For the first item that is added it works perfectly but for the second and subsequent items the dataSource.read() is not fired and the tree is not updated and the added item is not therefore selected.

Am I going about this the right way? Why would it work for the first item added but not subsequent items?

Many thanks in advance


1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 26 Nov 2013, 04:50 PM
Hi Huw,

I am afraid that the provided information is not sufficient enough in order to determine where exactly the problem comes from. Is it possible for you to prepare a sample project with mock data which isolates the behaviour? In this way we will be able to examine your exact scenario in details and provide you with a concrete recommendations.
Thank you in a advance for the cooperation.

Regards,
Alexander Valchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
TreeView
Asked by
Huw Lloyd
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or