jeudi 27 mars 2014

Creating and syncing a tree data object

I have a typical use case in which I dynamically create a tree. The user can not only add nodes but also edit nodes and once these nodes are edited, additional fields in the tree grid should be set. I was struggling to get this scenario working, but came up with the following solution:







First I can create a simple data object from a node with it's children (typically the root node). Then I can change some property values of this object and sync this with the tree. So, now I can first create the object, send the object to the server and once the server sends back the updated tree object, I can sync the data object with the existing tree. The problem with calling sync on the tree store itself is that it will send only updated records in an array to the server (so, a flattened tree).



I read a lot of posts trying to handle this scenario, so, maybe this could be of help. Note that the code makes use of the Underscore library.




Aucun commentaire:

Enregistrer un commentaire