Reputation: 4223
I have a TreeStore, which works fine, but every node has some nested data, so I made a new model for it and used the hasMany
association. But now the store loads nothing anymore. When I look into the records in the load
event, they're empty, but the browser tells me the Ajax request delivered everything like before.
This is what the node data looks like, when it comes from the server:
{ "path": "KEY_518693", "name": "KEY_518693", "data": [ { "branch": "KEY_518693", "primnav": "ETC", "X": 29261, "Y": 96492 }, ... ], "children": [ ... ], ... }
These are my model definitions:
TreeNode: { extend : 'Ext.data.Model', requires: [ 'DataRecord', 'Ext.data.association.HasMany' ], fields : [ { name: 'id' , type: 'string', mapping: 'path' }, { name: 'text', type: 'string', mapping: 'name' }, ... ], hasMany : { model: 'DataRecord', name : 'data' }
DataRecord: { extend: 'Ext.data.Model', fields: [ { name: 'branch' , type: 'string'}, { name: 'primnav', type: 'string' }, { name: 'X' , type: 'int' }, { name: 'Y' , type: 'int' } ] }
When I remove the association, the tree loads without problems. When I add data
to the fields it gets parsed into the tree, but as "raw" object and not as model instance.
Upvotes: 2
Views: 1201
Reputation: 23586
Please note that DataRecord has no field called treenode_id - so your hasMany association isn't complete. See docs for more info.
Upvotes: 2
Reputation: 4223
My approach had 2 problems.
'branch'
was rightUpvotes: 0