I have a functioning TreeView using and Ajax datasource that displays six root nodes, some of which have children. I want to automatically find a child node by its id and then select the child and expand it's parent node(s) in order to be visible. The problem I have is that the TreeView only loads the root nodes. Querying both the tree and datasource result in the child not being found, but I can find and select one of the six root nodes. I have tried setting LoadOnDemand(false), but it doesn't load all the child nodes.
I have not been able to wrap my brain about how to generate a full hierarchical dataset in my MVC controller to return as JSON that would have all the child nodes based on the examples I have seen. Am I missing a method/configuration setting to load all children in the tree automatically? I've been Googling and looking at lots of stuff, but maybe I'm just being dense.
Any pointers are appreciated!
Edit 23 June 2013
I finally found out the root of the problem. I found it in this post:
http://www.kendoui.com/forums/mvc/treeview/treeview-ajax-without-load-on-demand.aspx
The LoadOnDemand(false) does not work when using the MVC Wrapper and a HierarchicalDataSource. Once I converted to pure JavaScript initialization, everything started to work once I converted my data to a hierarchical structure. For those of you looking for a good library to convert flat tables into a hierarchical structure, take a look at this set of classes. They worked great for me. The only drawback is that it does not work with null parentIds.
http://blog.reneorban.com/2012/04/ashierarchy-generic-extension-method-to_12.html
I also made use of this Linq example to convert the model:
http://stackoverflow.com/questions/947831/c-sharp-algorithm-for-generating-hierarchy
Finally to find, select, and expand the necessary nodes in the tree, I leveraged this example:
http://www.kendoui.com/forums/ui/treeview/example-treeview-with-highlight-search-term.aspx
Hopefully others will find these references useful.
I have not been able to wrap my brain about how to generate a full hierarchical dataset in my MVC controller to return as JSON that would have all the child nodes based on the examples I have seen. Am I missing a method/configuration setting to load all children in the tree automatically? I've been Googling and looking at lots of stuff, but maybe I'm just being dense.
Any pointers are appreciated!
Edit 23 June 2013
I finally found out the root of the problem. I found it in this post:
http://www.kendoui.com/forums/mvc/treeview/treeview-ajax-without-load-on-demand.aspx
The LoadOnDemand(false) does not work when using the MVC Wrapper and a HierarchicalDataSource. Once I converted to pure JavaScript initialization, everything started to work once I converted my data to a hierarchical structure. For those of you looking for a good library to convert flat tables into a hierarchical structure, take a look at this set of classes. They worked great for me. The only drawback is that it does not work with null parentIds.
http://blog.reneorban.com/2012/04/ashierarchy-generic-extension-method-to_12.html
I also made use of this Linq example to convert the model:
http://stackoverflow.com/questions/947831/c-sharp-algorithm-for-generating-hierarchy
Finally to find, select, and expand the necessary nodes in the tree, I leveraged this example:
http://www.kendoui.com/forums/ui/treeview/example-treeview-with-highlight-search-term.aspx
Hopefully others will find these references useful.