Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

tree children: index vs. DOM treerows

1 view
Skip to first unread message

Jason S

unread,
Jul 10, 2008, 11:22:36 AM7/10/08
to
I'm a little confused... how does one obtain a handle to the <treerow>
element that corresponds to the PRInt32 "currentIndex" attribute of
the tree.view.selection? one is a sequential integer but <treerow>s
are a hierarchy. ???

Jason S

unread,
Jul 10, 2008, 11:44:51 AM7/10/08
to

larger context:
I have a small hierarchical tree (containing typically 5-20 items)
that I need to occasionally refresh when items are deleted/added. Not
a custom view; I add XUL DOM nodes manually per
http://developer.mozilla.org/en/docs/XUL_Tutorial:Trees. Each node has
some user data associated with it.

What I would like is that when the refresh happens, I'd like to figure
out which row (if any) has the focus via
tree.view.selection.currentIndex, get the user data from the DOM node,
then do my rebuild of the tree, and if the corresponding node exists
after the rebuild then I want to make sure that node is expanded & I
want to set the currentIndex to that node. (Note that the numerical
value of currentIndex can change if tree rows are added or deleted)
I'm confused about how to do this.

Neil

unread,
Jul 11, 2008, 4:51:35 AM7/11/08
to
Jason S wrote:

>Not a custom view; I add XUL DOM nodes manually per http://developer.mozilla.org/en/docs/XUL_Tutorial:Trees.
>

In that case the tree will automatically create a content view for you
(the other automatic view is a tree builder but that only applies when
using RDF and flags="dont-build-content"). The content view provides the
following extra methods:

nsIDOMElement getItemAtIndex(in long index);

long getIndexOfItem(in nsIDOMElement item);

item is either the <treeitem> or <treeseparator> element.

--
Warning: May contain traces of nuts.

Jason S

unread,
Jul 15, 2008, 10:08:59 AM7/15/08
to
On Jul 11, 4:51 am, Neil <n...@parkwaycc.co.uk> wrote:
> Jason S wrote:
> >Not a custom view; I add XUL DOM nodes manually perhttp://developer.mozilla.org/en/docs/XUL_Tutorial:Trees.

>
> In that case the tree will automatically create a content view for you
> (the other automatic view is a tree builder but that only applies when
> using RDF and flags="dont-build-content"). The content view provides the
> following extra methods:
>
> nsIDOMElement getItemAtIndex(in long index);
>
> long getIndexOfItem(in nsIDOMElement item);
>
> item is either the <treeitem> or <treeseparator> element.

ah! thanks!

0 new messages