[Users] Turning treepanel legend items into hyperlinks.

Eric Lemoine eric.lemoine at camptocamp.com
Wed May 12 10:22:22 CEST 2010


On Wed, May 12, 2010 at 9:10 AM, Andreas Hocevar <ahocevar at opengeo.org> wrote:
> Hi,
>
> On May 12, 2010, at 09:41 , Eric Lemoine wrote:
>
>> On Wed, May 12, 2010 at 7:50 AM, Andreas Hocevar <ahocevar at opengeo.org> wrote:
>>> Ext tree loaders are pretty extensible, and the loaders we have are no exception.
>>>
>>> The most elegant way, as Eric already pointed out, is to store the href somewhere, e.g. in the LayerStore. But there is no need to override a constructor or render method. The loader's createNode method is the one exposed to the API, and this is what you should override. See http://www.extjs.com/deploy/dev/docs/?class=Ext.tree.TreeLoader and look for the createNode method for an example.
>>
>> Your solution is indeed better. Thanks Andreas.
>>
>> One issue is that createNode receives a layer as opposed to a layer
>> record, so when overriding createNode one will need to find the layer
>> record corresponding to the layer. We could change the code so
>> createNode receives a layer record. We could also change LayerNode so
>> it can be configured with a layer record; currently the "layer" option
>> can reference a layer or a layer name, so we could extend this so it
>> can also reference a layer record.
>
> Why so complicated? We have a LayerStore::getByLayer method already. So the createNode method could look like this:
>
> var myLoader = GeoExt.tree.LayerLoader({
>    createNode: function(attr) {
>        attr.href = attr.store.getByLayer(attr.layer).get("href");
>        GeoExt.tree.LayerLoader.prototype.createNode.call(this, attr);
>    }
>    // ...
> });

I had forgotten about the getByLayer method. So I think it's good
enough like this. Thanks,


-- 
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : eric.lemoine at camptocamp.com
http://www.camptocamp.com


More information about the Users mailing list