Mozilla XUL Element and Script Reference

Contents  Quick Reference

Tree

A container which can be used to hold a tabular or hierarchical set of rows of elements. The tree may contain any number of rows and any number of columns. Each row of the tree may contain child rows which are displayed indented from the parent. The contents of a tree are most commonly generated from an RDF datasource.

The example below creates a tree with two columns and three rows.

Example:

    <tree flex="1">
      <treecols>
        <treecol id="breakfast" label="Breakfast" flex="1"/>
        <treecol id="lunch" label="Lunch" flex="1"/>
      </treecols>
      <treechildren>
        <treeitem>
          <treerow>
            <treecell label="Cheese Omelet"/>
            <treecell label="Ham Sandwich"/>
          </treerow>
        </treeitem>
        <treeitem>
          <treerow>
            <treecell label="Waffles"/>
            <treecell label="Caesar Salad"/>
          </treerow>
        </treeitem>
        <treeitem>
          <treerow>
            <treecell label="Grapefruit"/>
            <treecell label="Cheeseburger"/>
          </treerow>
        </treeitem>
      </treechildren>
    </tree>

Attributes:

Attributes inherited from XUL Element

enableColumnDrag    Moz0.9.5

When set to 'true', the user may drag the column headers around to change the order that they are displayed in.

flags

Set this attribute to 'dont-build-content' for a template generated tree. For trees that have their content placed directly inside the tree or have a custom view object, this flag should not be used.

hidecolumnpicker

When set to false, a drop-down will appear in the upper right corner of the tree, which the user may use to show and hide columns. When set to true, the column picker will be hidden. The default value is false.

onselect

This event is sent to an tree when a row is selected, or whenever the selection changes. The user can select multiple rows by holding down Shift or Control and click on a row. The onselect event will be sent for each item added or removed to the selection.

seltype    Moz0.9.8

Used to indicate whether multiple selection is allowed.

Properties and Methods:

Properties and Methods inherited from XUL Element

builderView

currentIndex

Set to the index of the currently selected row in the tree. If no row is selected, the value will be -1. You can assign a value to this property to change the selected row.

currentView

enableColumnDrag    Moz0.9.5

When set to 'true', the user may drag the column headers around to change the order that they are displayed in.

firstOrdinalColumn

A reference to the first treecol element, which or may not be the first column displayed in the tree.

selectionHead

selectionTail

singleSelection

Gets and sets the value of the seltype attribute.

treeBoxObject

view

The view for the tree, which is the object that generates the data to be displayed. You can assign an object which implements nsITreeView to this property.