Hi,<div><br></div><div>I&#39;m trying to make an  MVC app with a panel that contains a LayerTree using EXTJS4 and GeoExt2. </div><div><br></div><div>Basically the problem is that the layertree needs to have the layer store available on init but data are actually not ready, so layer tree can be there before the map (or layer store) is available. The result of this is that layers are not displayed in the tree. I tried to reload the stores without any success. Do you have any hint?</div>
<div><br></div><div>Thanks a lot</div><div><br></div><div>I have then a </div><div><div><br></div><div>Ext.define(&#39;Pandora.view.LayersTree&#39;, {</div><div>    // Ext.panel.Panel-specific options:</div><div>    extend: &#39;GeoExt.tree.Panel&#39;,</div>
<div>   store: &#39;LayersTree&#39;,</div><div>.....</div><div><br></div><div><br></div><div>then </div><div><div>Ext.define(&#39;Pandora.store.LayersTree&#39;,  {</div><div>    extend: &#39;Ext.data.TreeStore&#39;,</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>model: &#39;GeoExt.data.LayerTreeModel&#39;,</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>root: {</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>expanded: true,</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>children: [<span class="Apple-tab-span" style="white-space:pre">        </span>{<span class="Apple-tab-span" style="white-space:pre">                        </span></div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>plugins: [{</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                </span>ptype: &#39;gx_layercontainer&#39;,</div><div><span class="Apple-tab-span" style="white-space:pre">                                                        </span></div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>loader: {</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                </span>store: Ext.data.StoreManager.lookup(&#39;LayersMap&#39;),//map.layers,<span class="Apple-tab-span" style="white-space:pre">        </span></div><div><span class="Apple-tab-span" style="white-space:pre">                                        </span>createNode: function(attr) {</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                                </span>// add a WMS legend to each node created</div><div><span class="Apple-tab-span" style="white-space:pre">                                                </span>if(!(attr.layer instanceof OpenLayers.Layer.OSM || attr.layer instanceof OpenLayers.Layer.Vector))</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                                </span>{</div><div><span class="Apple-tab-span" style="white-space:pre">                                                        </span>attr.component = {</div><div><span class="Apple-tab-span" style="white-space:pre">                                                                </span>xtype: &quot;gx_wmslegend&quot;,</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                                                </span>layerRecord: mapPanel.layers.getByLayer(attr.layer),</div><div><span class="Apple-tab-span" style="white-space:pre">                                                                </span>showTitle: false,</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                                                </span>// custom class for css positioning</div><div><span class="Apple-tab-span" style="white-space:pre">                                                                </span>// see tree-legend.html</div><div>
<span class="Apple-tab-span" style="white-space:pre">                                                                </span>cls: &quot;legend&quot;</div><div><span class="Apple-tab-span" style="white-space:pre">                                                        </span>};</div><div><span class="Apple-tab-span" style="white-space:pre">                                                </span>};</div>
<div><span class="Apple-tab-span" style="white-space:pre">                                                </span>return GeoExt.tree.LayerLoader.prototype.createNode.call(this, attr);</div><div><span class="Apple-tab-span" style="white-space:pre">                                        </span>}</div>
</div><div><br></div><div>and the layerstore</div><div><br></div><div><div>Ext.define(&#39;Pandora.store.LayersMap&#39;, {</div><div>    extend: &#39;GeoExt.data.LayerStore&#39;,</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>autoload : false</div>
</div><div><br></div><div>and finally </div><div><br></div><div>in the map I simply do</div><div><br></div><div>store: &#39;LayersMap&#39;,</div><div>...</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>Ext.data.StoreManager.lookup(this.store).bind(map);<span class="Apple-tab-span" style="white-space:pre">        </span></div>
<div><br></div><div><br></div><div><br></div><div><br></div>- Antonio
</div><div style="font-size:1em"><div style="max-width:300px!important;color:#eee!important;border-color:#111!important;border-width:0px!important;background-color:rgba(17,17,17,0.9)!important;font-size:16px!important;padding:8px!important;overflow:visible!important;text-align:left!important">
<div class="translation" style="color:inherit;background-image:none;border:none;background-repeat:initial initial">il</div><div class="additional" style="color:inherit;background-image:none;border:none;background-repeat:initial initial">
<div style="color:inherit;background-image:none;border:none;background-repeat:initial initial"><b>articolo</b>: <i>il, la, le, i, lo, l &#39;, gli, lo stesso</i></div></div></div></div>