PDA

View Full Version : scrollbar on dynamic tree


lizac
06-25-2004, 12:34 AM
scrollbar works on a tree when the dataset is statically declared in the lzx file but not when the same dataset reads its data from an external xml file (see sample attached).

Am I missing something obvious ?

antun
06-28-2004, 09:05 AM
I've filed this as a bug, and I'll let you know as soon as I find out any more.

-Antun

lizac
08-03-2004, 09:22 AM
Any news on this ?

antun
08-05-2004, 08:33 AM
Unfortunately not - it's not fixed yet, so I'm not sure if it will be for the next release.

-Antun

pablo
12-08-2004, 12:36 AM
Hi lizac,

Apologies for the very late response!

I'll first start by providing two different solutions before explaining what the problem was.

The first option is to add an onopen event handler in your tree's root (see highlighted region):
<canvas>
<bluestyle name="defaultstyle" isdefault="true"/>
<alert id="errMsg" title="Error"/>
<include href="lz/tree.lzx" />
<splash/>

<dataset name="projects" request="true" type="file"
src="file:tikalProjects.xml"
onerror="errMsg.setAttribute('text',
'dataset Error: getting data from '+this.src+' !');
errMsg.open();"
ontimeout="errMsg.setAttribute('text',
'dataset Timeout: getting data from '+this.src+' !');
errMsg.open();"
/>

<view name="main" width="300" height="300" clip="true">
<view name="contents">
<tree datapath="projects:/root" autoscroll="true" showroot="false"
text="$path{'@name'}" open="$path{'@isopen'}">
<method event="onopen" args="o">
if (typeof(o) == 'string') {
this.setAttribute('open', (o == 'true'));
}
</method>
<tree datapath="*" isleaf="$path{'@isleaf'}" text="$path{'@name'}">
<method event="onactivate">
var url = this.datapath.xpathQuery('@url');
if (url != null) {
LzBrowser.loadURL(url,'tikalMainView');
}
</method>
</tree>
</tree>
</view>
<scrollbar/>
</view>
</canvas>
Alternatively, you can go and fix basetree, located in lps/components/base/basetree.lzx. Find the _setOpen() method and, in what I believe should be line 231, replace
if (!_initcomplete && typeof(o) == "string") {with/* removed !_initcomplete */
if (typeof(o) == "string") {Since datapaths always resolve to strings, basetree has special logic to re-typecast its boolean attributes like open, selected, and isleaf. The open attribute controls the visibility of a tree's "children" view and, when it's set to a string instead of a boolean, the height of the tree doesn't get updated (i.e. it remains 0). In turn, this affects the scrollbar because it doesn't know that the content height has changed.

Let me know if this helps and thanks for your patience!

Cheers,
pablo

lizac
12-08-2004, 02:04 AM
Hi Pablo,

thank you for this patch on basetree. It works very well for me.
Is it to be commited to the laszlo project in a forthcoming release ?

--
Laurent IZAC

pablo
12-08-2004, 12:07 PM
Hi Laurent,

No problem! Yes, the fix will be committed to the next release.

pablo