[fusion-users] Get layer name from Legend right-click

Tom van der Putte tom at vdputte.nl
Fri Apr 16 03:42:28 EDT 2010


 Hi Mike,
 Thanks for the explanation, so far I think I understand.
 What I meant was the following:
 I can't figure out where I can get the layer variable from
(containing the layer or layername that was right-clicked). You're
passing the layer variable, but how do you get it to contain the right
layer. Thats the main issue here. To simplify my problem:
 I have a context menu for the legend, containing an item: 'alert
layer name', which functionality would be to do just that. I'd add
these to lines to the Legend.Legendrenderer.
 this.alertLayernameAction= new
Jx.Action(OpenLayers.Function.bind(alert( lyrName),null)); // (or
something like that?)
 this.alertLayer= new Jx.MenuItem(this.executeRasterQueryAction,
{label:OpenLayers.i18n('alert layer name')});
 My issue her is where do I get lyrname from? Is the name of the node
that was right-clicked available somewhere?
 Hope this is clearer, thanks so much!
 Tom
 On Thu 15/04/10 17:25 , Mike Adair madair at dmsolutions.ca sent:
 Tom,
 Then your getRasterQuery method would look like:
 function getRasterQuery(layer) {
     var temp = layer.name;
 ...
 }
 For the OpenLayers.Function.bind method, the first arg is the method
to 
 be bound, the second arg is the object to bind to (object will be
'this' 
 inside the method), and then the rest of the arguments will be
passed to 
 the bound method as arguments.
 Mike
 Tom van der Putte wrote:
 > Hi Mike,
 >
 > I was trying your solution, but I'm still a bit confused.
 >
 > This is my current code (within Legend.LegendRenderer)
 >
 > this.executeRasterQueryAction = new 
 > Jx.Action(OpenLayers.Function.bind(this.getRasterQuery, this));
 > this.executeRasterQueryItem = new 
 > Jx.MenuItem(this.executeRasterQueryAction, {label: 
 > OpenLayers.i18n('Execute raster query')});
 >
 > According to your explanation, the first line should then be:
 >
 > this.executeRasterQueryAction = new 
 > Jx.Action(OpenLayers.Function.bind(this.getRasterQuery, this,
layer));
 >
 > Or am I wrong here? But how do I get the reference to the layer
thats 
 > clicked? Does that make sense what I'm saying? :) I'm not really
into 
 > the whole binding stuuf yet. Getting there though...
 >
 > Cheers,
 > Tom
 >
 >
 >
 > On Thu 15/04/10 15:52 , Mike Adair  sent:
 >
 >     Tom,
 >
 >     The menu items are only bound to the legend tree items/folders
at
 >     this
 >     point. I think what you would need to do is bind whatever
object you
 >     need when setting up your onclick event, eg. the existing code
 >     looks like:
 >     onClick:
 >     OpenLayers.Function.bind(this.collapseBranch, this,
this.oRoot)
 >
 >     but you probably want:
 >
 >     onClick:
 >     OpenLayers.Function.bind(this.collapseBranch, this,
this.oRoot, layer)
 >
 >     (or similar) and then in the method being bound, layer will
appear as
 >     one of the arguments.
 >
 >
 >     Mike
 >
 >
 >     Tom van der Putte wrote:
 >     > Hi All,
 >     >
 >     > When right-clicking an item in the legend, a context manu
appears.
 >     > I've added a entry to this menu, and clicking on it results
in a
 >     > certain function beeing executed. However, I want to check
if the
 >     item
 >     > that was right-clicked in the legend is of a certain type.
How can I
 >     > get to the layer name? I found something like targetFolder
in the
 >     > legend widget, but this obviously goes only for the folders?
 >     >
 >     > Cheers,
 >     >
 >     > Tom
 >     >
------------------------------------------------------------------------
 >     >
 >     > _______________________________________________
 >     > fusion-users mailing list
 >     > 
 >     
 >     > http://lists.osgeo.org/mailman/listinfo/fusion-users
 >     
 >     >
 >
 >     -- 
 >     Michael Adair
 >     Senior Software Architect
 >     DM Solutions Group Inc.
 >
 >     Office: (613) 565-5056 x26
 >     
 >     
 >     http://www.dmsolutions.ca
 >     

	www.dmsolutions.ca>
 >     http://research.dmsolutions.ca
 >     
 >
 >
 >
 -- 
    Michael Adair
    Senior Software Architect
    DM Solutions Group Inc.
    Office: (613) 565-5056 x26
    http://www.dmsolutions.ca
    http://research.dmsolutions.ca
 

Links:
------
[4] http://www.dmsolutions.ca
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/fusion-users/attachments/20100416/9649815b/attachment.html


More information about the fusion-users mailing list