Re: Nested Content Tree Using Custom Tree View

[email protected] Sat, 29 Mar 2014 09:09:58 -0700 (PDT)
Newsgroups gmane.comp.mozilla.devel.xpfe
Message-ID <[email protected]>
On Monday, March 17, 2014 5:11:20 PM UTC-6, [email protected] wrote:
> I have a tree that is currently a standard content tree; three columns for multiple rows of data.  The basic code is as follows:
> 
> 
> 
> <tree
> 
> 	editable="false"
> 
> 	id="comicsTree"
> 
> 	enableColumnDrag="true"
> 
> 	hidecolumnpicker="true"
> 
> 	seltype="multiple"
> 
> 	flex="1">
> 
> 
> 
> <treecol id="pub" label="Publisher" flex="2"persist="width ordinal" />
> 
> <splitter />
> 
> <treecol id="title" label="Title" persist="width ordinal" />
> 
> <splitter />
> 
> <treecol id="series" label="Series" persist="width ordinal" />
> 
> 
> 
> 
> 
> 
> 
> I populate the tree children using JavaScript like this (the data is in an a array called comicsArr).
> 
> 
> 
> var formatData = {
> 
>   rowCount : comicsArr.length,
> 
>   getCellText : function(row,column) {
> 
>     var line = comicsArr.split("\t");
> 
>       switch (column.id) {
> 
>         case "pub":
> 
>           return line[0];
> 
>         case "title":
> 
>           return line[1];
> 
>         case "series":
> 
>           return line[2];
> 
>         default :
> 
>           return false;
> 
>       } // end switch
> 
>     },
> 
>   setTree: function(treebox){this.treebox = treebox;},
> 
>   isContainer: function(row){return false;},
> 
>   isSeparator: function(row){return false;},
> 
>   isSorted: function(row){return false;},
> 
>   getLevel: function(row){return 0;},
> 
>   getImageSrc: function(row,col){return null;},
> 
>   getRowProperties: function(row,props){},
> 
>   getCellProperties: function(row,col,props){},
> 
>   getColumnProperties: function(colid,col,props){}
> 
> }
> 
> 
> 
> document.getElementById(comicsTree).view=formatData;
> 
> 
> 
> 
> 
> This all works fine.  However, what I want to do is modify my tree such that the content is nested.  I.E. - All comics published by Marvel will be nested under the row Marvel.  Likewise, all titles of the same name, say Captain America, will be under the nested row Captain America, listed by Series.
> 
> 
> 
> 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?
> 
> 
> 
> Thanks in advance,
> 
>  - JPR

Neil,

As always, you're a tremendous resource.  Your code example is exactly what I'm looking for.

I have it running in a test dialog.  I just need to work my way through it to understand what's going on and modify it to my purposes.

Thanks for the help.
 - JPR