View Full Version : DIfferent models for TreeNodes (Nested data associations)

23 Nov 2012, 2:45 AM

after already tweaked my code a lot to get this working I noticed a new behavior in this issue with 4.1. I want to achieve a Tree, where the root of the TreeStore is of the model "MAP". All subsequent children nodes should be of the type "LAYER". Of course I have configured the TreeStore with one model, the model "MAP" and the MAP/LAYER models are associated (hasMany/belongsTo)

When I want to load new maps, I set a new RootNode (JSON object). NOW COMES THE PROBLEM: All the nested data is interpreted as MAP models. I have no clue how I could set a modell/class type on my children node so they become LAYERs. This was the behavior in Ext 4.0 and party in 4.1...
My solution was a decorate function, copying my LAYER properties & methods to each child node (similar to the NodeInterface decoration)

What changed in 4.1 is that when I later dynamically add a new node (for instance by dragging a LAYER model on the tree), the new node SUDDENLY KEEPS its model type (in most cases)

This is all very awkward and working with trees seems to be a total mess in ExtJS 4.X so far. But of course it could also be that I simply missed a config which would turn all my nested children in the desired model...

Help ver much appreciated!!!

Thanks a lot.

26 Nov 2012, 7:47 AM
The TreeStore will only be able to use 1 model.

26 Nov 2012, 8:33 AM
The strage thing is then, that since 4.1 sometimes I have different models in the tree when inserting nodes later (Drag &Drop, etc). Is it planned to have more models and make use of model relationships in the future?

26 Nov 2012, 8:35 AM
Probably out of scope for Ext JS 4.x