Re: Nested Content Tree Using Custom Tree View

Neil <[email protected]> Tue, 18 Mar 2014 09:40:48 +0000
Newsgroups gmane.comp.mozilla.devel.xpfe
Message-ID <[email protected]>
[email protected] wrote:

>My problem is: how do I get the custom tree view to do this or is it even possible?  I've tried about two dozen different approaches to this and can't get anything to work.  Can anyone out there point me in the right direction?
>  
>
Once you start nesting rows things get very complicated very quickly. 
The relevant methods are:

    * rowCount: Must be kept up to date as parent rows are opened and closed
    * isContainer: Must return true for parent rows. (Can return true
      for child rows if isContainerEmpty returns true too.)
    * getParentIndex: Returns -1 for top-level rows.
    * hasNextSibling: Must return true if a parent has a sibling. Note
      that afterIndex will be one of its descendant rows, this may or
      may not be useful for you.
    * getLevel: Must return the depth (indentation) of the row
    * toggleOpenState: Called on non-empty parent rows when the [+] is
      clicked. Must call treeBoxObject.rowCountChanged to notify the
      tree of how many rows were added or removed.

Of course you also need to remember to set the primary="true" attribute 
on one of your tree columns.

There are a number of wrappers that do some of the legwork for you, for 
instance this is one I wrote about 10 years ago: 
http://pastebin.mozilla.org/4618616 (note that these days you need to 
install that file as part of an extension but as I recall the original 
version worked in Netscape 7 and probably even Firefox 1.0 too).

-- 
Warning: May contain traces of nuts.