Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ExtJS data store for tree

I've got a basic ExtJS question, which I can't seem to resolve based on reading the docs and searching. Currently I have a TreePanel that loads JSON directly from a URL. I'm trying to separate the data from the view, so that I can also use that data to feed into an OpenLayers map (using GeoExt). How can I point a TreePanel to an Ext.data.Store rather than to a URL?

like image 279
Drew Dara-Abrams Avatar asked Aug 24 '26 10:08

Drew Dara-Abrams


1 Answers

TreePanels use TreeLoaders, not Stores, to load data. The reason is that trees require hierarchical data, while Stores are flat table structures and do not support hierarchies. The basic data objects are also different (Record vs. Node). Of course you could store your own hierarchical data in a Store using parent/child keys, but there is not anything like this built in for Ext components at this time. If you are trying to cache tree data, you might have to roll your own solution for that.

EDIT: Now that Ext 4 is out, this answer only applies to Ext 3. Ext 4 has a (mostly) unified data model now and trees use a TreeStore (with an additional NodeInterface applied to the models) and no longer have a separate TreeLoader class.

like image 170
Brian Moeskau Avatar answered Aug 26 '26 22:08

Brian Moeskau



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!