How can a tree change its 'rows' attribute automatically?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How can a tree change its 'rows' attribute automatically?

peter.kehl
Hi,

In my XPI for Firefox, I've got a tree, whole created in Javascript via DOM (not via a data-based view; the only method I customise in the view is setCellText; the rest of view methods just forward to the original view).

I'd like the tree to use the whole height available within its parent container. When the user resizes the window, I'd like the tree to change its height automatically. Can that be done and how?

But it seems that 'rows' attribute only accepts numbers. Is there any way around it? If I have to calculate and update 'rows' attribute on window resize, then please
- what's the window resize event name
- how do I get the height of a tree row? (So I can calculate the value of 'rows')

Thank you in advance.

var tree= document.createElementNS( XUL_NS, 'tree' );
    tree.setAttribute( 'id', 'settingsTree');
    tree.setAttribute( 'editable', ''+(targetFolder===null) );
    tree.setAttribute( 'seltype', 'single' );
    tree.setAttribute( 'hidecolumnpicker', 'true');
    tree.setAttribute( 'hidevscroll', 'false');
    tree.setAttribute( 'class', 'tree');
    tree.setAttribute( 'onblur', 'onTreeBlur()' );
    tree.setAttribute( 'flex', '1');
    tree.setAttribute( 'rows', '25');
   
    var settingsBox= document.getElementById('SeSettingsBox'); // This is a vbox in my tree.xul file
    settingsBox.appendChild( tree );
   
tree.xul:

<window id="yourwindow" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml">
<vbox id="SeSettingsBox"></vbox>
</window>
_______________________________________________
dev-tech-xul mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xul
Reply | Threaded
Open this post in threaded view
|

Re: How can a tree change its 'rows' attribute automatically?

Neil-4
[hidden email] wrote:

>I'd like the tree to use the whole height available within its parent container.
>  
>
Your tree is already using the whole height available within its parent
container, without the use of the rows attribute.

><window id="yourwindow" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml">
><vbox id="SeSettingsBox"></vbox>
></window>
>  
>
But your parent container isn't using the whole height available within
the window. Add flex="1" to the vbox to fix that.

--
Warning: May contain traces of nuts.
_______________________________________________
dev-tech-xul mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xul
Reply | Threaded
Open this post in threaded view
|

Re: How can a tree change its 'rows' attribute automatically?

peter.kehl
Neil,

Thank you. That fixed it.

On Friday, December 13, 2013 10:29:48 AM UTC+11, Neil wrote:
> Your tree is already using the whole height available within its parent
>
> container, without the use of the rows attribute.
> But your parent container isn't using the whole height available within
>
> the window. Add flex="1" to the vbox to fix that.
_______________________________________________
dev-tech-xul mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xul