I'm using Teleriks Kendo-UI with MVC to build a MVVM model for a treeview like this ...
var viewModel = kendo.observable({
isVisible: true,
items: kendo.observableHierarchy(@Html.Raw(Json.Encode(Model.items))),
....
All is good, but then I have some signalR clients on the page that accept "events" for the model so I added ...
addItem: function(parentId, item){
// how do query the hierarchy?
},
deleteItem: function(itemId) {
// again how do i query the hierarchy?
},
... to the above model in order to accept these event notifications when called from my signalR code.
The problem I have is that I have a hierarchy but no idea how to get the data item in this context where the item has the given id then add the given item to its children.
I am assuming this is the right approach though right?
My theory being that "x happened on server", that results in "notify client" which calls "add item" passing a parentid and the item to be added to the tree. By adding to the model the item should then "just appear in the tree".
But how do I query the item collection and its children recursively on the client because I don't have linq in this context?