View Full Version : Incubator Opttree
opensource
07-01-2006, 07:18 PM
Is there a documentation on opttree that explains in detail how to use the tree? It seems to be that lot of people are suggesting using the opttree, however the limitation is on proper documentation.
Anyway.
Thanks.
spoco2
08-29-2006, 09:10 PM
It is very limited in documentation, one of the reasons it's still in the incubator is my guess. However by using the test case provided, and looking at the code it's not terribly hard to work out.
I've been using it a fair bit, so may be able to answer issues you may be having with it.
Hi Senshi,
May I ask you two questions re opttree please?
1. I have a dataset with a certain depth linked to an opttree object. However, I need to limit the number of levels the opttree shows. For example, my dataset looks something like:
<dataset name="ds">
<level1 name="abc11">
<level2 name="abc121" />
<level2 name="abc122" />
<level2 name="abc123" />
</level1>
<level1 name="abc21">
<level2 name="abc221" />
<level2 name="abc222" />
<level2 name="abc223" />
</level1>
<level1 name="abc31">
<level2 name="abc321" />
<level2 name="abc322" />
<level2 name="abc323" />
</level1>
</dataset>
... and I don't want to show the Level2 nodes in the opttree; only Level1 ones . In other words, can my opttree show only:
abc11
abc21
abc31
2. It is possible to show/hide the tree lines. Is it possible to hide the collapse/expand thumb on the left; the one with +/- sign in it? I'd like to collapse/expand a node by just clicking on it.
Thanks in advance!
Cheers,
Naso.
spoco2
05-19-2008, 05:52 PM
I'll answer if you like:
Yes you can filter which nodes you show. In your tree instantiation the nodepath attribute is usually: nodepath="*". This means it'll create treenodes for every node in the dataset. You can change the nodepath to be ="level1" and that should work.
You can also have an expander, in my code I have one defined as such on the treenode:
<view name="exphouse" width="10" height="10">
<view name="expander" resource="tree_toggle_rsc" initstage="early" visible="${this.parent.parent.haschildren}">
<attribute name="open" value="${this.parent.parent.open}" />
<handler name="onopen" args="theval">
if(theval){
this.setResourceNumber(2);
}
else{
this.setResourceNumber(1);
}
</handler>
<handler name="onclick">
this.parent.parent.setOpen(!this.parent.parent.ope n );
</handler>
</view>
</view>
The outer view is only there for spacing for me, so don't worry about that if you don't want it. The haschildren attribute is stored on the dataset and is set by the business objects that the data represents, but you can set it by using the various data nethods to ascertain if a given node has children.
Thanks heaps Spoco2!
I experimented with the nodepath attribute but the result is not what I expected. When I set a certain xpath in nodepath, the application stops responding once I try to expand a node. Of course I may be doing something not quite right; I'll need to explore this.
Re the expander, I got it.
Thanks again,
Naso.
Spoko2,
It's all working fine now. Thanks again!
Naso.
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.