I have a site I am working on, and need to build a treeview for some admin functions. KnockoutJS would be a huge help here in terms of editing items and modifying the treeview. That being said, I am not sure how to accomplish it. I am very much a novice KnockoutJS user (but not a new web developer).
Most of the examples I see of working with Lists and Collections in Knockout seem to take a "foreach" approach to generating the HTML and binding data. Since I am building a treeview (<ul> and <li> objects) what I really need to do is use recursion to build the HTML.
My data objects do have a basic structure including Id, Name and a Children collection which in turn hosts other objects of the same type.
The environment I'm working in is an
ASP.NET MVC 4 project, so I don't care much "how" this gets done. I could build the object in code behind using C# (what I'm doing now), but I need a way to markup the HTML so it binds to the ViewModel objects/properties. I am also open to using JavaScript to create the DOM objects, or if I can build the HTML using a foreach loop and KnockOut, all the better.
I did see some source code in a library that accomplished this, but the control was so "fully featured" that trying to narrow it down to just the basics was overwhelming me.
If anyone has any suggestions, ideas or examples of how to create a very vanilla ul/li markup using KnockOut, I'd be very grateful. Thank you. -Todd