[Chameleon] JSTreeView

Paul Spencer pagameba at magma.ca
Fri Aug 13 07:39:06 EDT 2004


Jeff,

from the WMSBrowser widget's use of the JSTreeView ...

<cwc2 type="SharedResource" name="WMSLAYERS" ENABLEJS="true"/>

<cwc2 type="JSTreeView" JSSHAREDRESOURCE="WMSLAYERS" 
LEAFONCLICK="parent.myTreeClicked" NODEONCLICK="parent.myTreeClicked" 
NODEDATAFIELD="layer_id" NODELABELFIELD="title" NODEICONFIELD="icon" 
NODEICONOPENFIELD="iconopen" LEAFLABELFIELD="title" LEAFICONFIELD="icon" 
LEAFDATAFIELD="layer_id" NODECLASS="treeLink" LINKCLASS="treeLink" 
NODESELECTEDSTYLE="background-color:#e3f0f0;border-color:#b2c4c4;font-weight:bold" 
NODENORMALSTYLE="background-color:#ffffff;border-color:#ffffff;font-weight:normal"/>

The widget that populates the shared resource is the WMSCache widget, 
you can check there for specific code examples, but in general the 
process is to create an array like:

$this->maSharedResourceWidgets[$this->mszSharedResource] = array();

The structure of the array looks like this:

['top'][0]['node'][0]['nodedatafield']
['top'][0]['node'][0]['nodelabelfield']
['top'][0]['node'][0]['nodeiconfield']

['top'][0]['node'][1]['leaf'][0]['leafdatafield']
['top'][0]['node'][1]['leaf'][0]['leaflabelfield']
['top'][0]['node'][1]['leaf'][0]['leaficonfield']

['top'][0]['node'][2]['leaf1'][0]['leafdatafield']
['top'][0]['node'][2]['leaf1'][0]['leaflabelfield']
['top'][0]['node'][2]['leaf1'][0]['leaficonfield']

['top'][0]['node'][3]['node1'][0]['leaf2'][0]['leafdatafield']
['top'][0]['node'][3]['node1'][0]['leaf2'][0]['leaflabelfield']
['top'][0]['node'][3]['node1'][0]['leaf2'][0]['leaficonfield']

['top'][0]['node'][4]['node1'][1]['leaf3'][0]['leafdatafield']
['top'][0]['node'][4]['node1'][1]['leaf3'][0]['leaflabelfield']
['top'][0]['node'][4]['node1'][1]['leaf3'][0]['leaficonfield']


['top'][1]['node'][0]['nodedatafield']
['top'][1]['node'][0]['nodelabelfield']
['top'][1]['node'][0]['nodeiconfield']

['top'][1]['node'][1]['leaf4'][0]['leafdatafield']
['top'][1]['node'][1]['leaf4'][0]['leaflabelfield']
['top'][1]['node'][1]['leaf4'][0]['leaficonfield']

And my incredible ascii art version of this tree is:

top
|
+- node
|  |
|  +- leaf
|  |
|  +- leaf1
|  |
|  +- node1
|     |
|     +- leaf2
|     |
|     +- leaf3
|
+- node2
    |
    +- leaf4

At least, I think that's how it works ;)  I would recommend getting the 
wmsbrowser to work and then putting a print_r($sr); in 
wmscache.widget.php at the end after the line that says $sr = array( 
"WMSSERVERS" =>  $axServers ); to confirm the structure.

Cheers,

Paul

PS since you are actively working on this, it would be great if you kept 
some notes and stuck them in the chameleon wiki or at least sent them to 
me to help out with generating useful documentation :)



Jeff Hamm wrote:

> I would like to replace my XMLThemeLegend with a JSTreeView.
> 
> In my template file, I first created a shared resource like this:
> <cwc2 TYPE="SharedResource" NAME="MyTree" ENABLEJS="true">
> <NODEDATAFIELD value="mydata"/>
> <NODELABELFIELD value="mylabel"/>
> </cwc2>
> 
> Then I placed a JSTreeView widget in my template like this:
> 
> <cwc2 type="JSTreeView" JSSharedResource="MyTree">
> </cwc2>
> 
> This is sufficient to generate a folder icon on my map (but no label). I
> obviously need to build appropriate objects (akin to Themes/Groups in
> XMLThemeLegend) for the tree. My question is how/where this should be
> done? Do I declare the NODE* and LEAF* attributes in the template (as
> above, but with javascript calls) or  a renderer file (as in the
> XMLThemeLegend approach).
> 
>>From previous postings to this list
> (http://lists.maptools.org/pipermail/chameleon/2004-February/000499.html)
> all I know is that it's 'tricky'. However,if anyone is able to provide a
> sample/psuedo JSTreeView SharedResource widget, I'd have a better idea
> of which way to turn.
> 
> Thanks,
> 
> Jeff Hamm
> Yukon Land Use Planning Council
> 
> 
> _______________________________________________
> Chameleon mailing list
> Chameleon at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/chameleon
> 

-- 
  -----------------------------------------------------------------
|Paul Spencer                           pspencer at dmsolutions.ca   |
|-----------------------------------------------------------------|
|Applications & Software Development                              |
|DM Solutions Group Inc                 http://www.dmsolutions.ca/|
  -----------------------------------------------------------------



More information about the Chameleon mailing list