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