tree
element describes a table with one or more columns. Contrary to the listbox
element, the cells can be edited. Note that contrary to the original XUL specification, the tree element can not represent hierarchical trees.
treecols
element describes the header of a tree
treecol
element describes one column of the treetreechildren
element describes the content of the treetreeitem
and treerow
elements describes one rowtreecell
element describes one celltree
cells are editable. editable
attribute on the tree
elementeditable
attribute on the associated treecol
elementeditable
attribute on the associated treecell
elementview
attribute allows to get or set characteristics for tree cells. The associated objet is a NSITreeView
and has the following API:public class NSITreeView |
---|
Modifier and Type | Method and Description |
---|---|
String | getCellText(int row, int column)
Return the value for one cell. Same result as getCellValue
|
String | getCellValue(int row, int column)
Return the value for one cell
|
boolean | isEditable(int row, int column)
Return the editability for one cell
|
void | setCellText(int row, int column, String value)
Set the value for one cell. Same result as setCellValue
|
void | setCellValue(int row, int column, String value)
Set the value for one cell
|
<window id="hello" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" > <script> function select() { var index = document.getElementById("theTree").currentIndex; var view = document.getElementById("theTree").view; view.setCellText(index, 0, "TOTO"); } </script> <tree id="theTree" onselect="select()"> <treecols> <treecol label="First name" /> <treecol label="Last name" /> </treecols> <treechildren> <treeitem> <treerow> <treecell label="Bullock" /> <treecell label="Sandra" /> </treerow> </treeitem> <treeitem> <treerow> <treecell label="Roberts" /> <treecell label="Julia" /> </treerow> </treeitem> </treechildren> </tree> </window>
getCellText(int row, int column)
method of the tree viewsetCellText(int row, int column, String value)
method of the tree view<window id="hello" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" > <tree id="theTree"> <treecols> <treecol label="First name" /> <treecol label="Last name" /> </treecols> <treechildren> <treeitem> <treerow> <treecell id="theCell" label="Bullock" /> <treecell label="Sandra" /> </treerow> </treeitem> <treeitem> <treerow> <treecell label="Roberts" /> <treecell label="Julia" /> </treerow> </treeitem> </treechildren> </tree> </window>We can change the text for the first cell by either:
var view = document.getElementById("theTree").view; view.setCellText(0, 0, "NewName");or:
var cell = document.getElementById("theCell"); cell.label = "NewName";
tree
leveltreeitem
leveltreecell
level<window id="hello" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" > <tree id="theTree"> <treecols> <treecol label="First name" /> <treecol label="Last name" /> </treecols> <treechildren> <treeitem> <treerow> <treecell label="Bullock" style="background-color:yellow; font-size: 20pt" /> <treecell label="Sandra" /> </treerow> </treeitem> <treeitem> <treerow> <treecell label="Roberts" /> <treecell label="Julia" /> </treerow> </treeitem> </treechildren> </tree> </window>
onselect
command on the tree
allows to listen to row selection events. For example:<window id="hello" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" > <script> function select() { var index = document.getElementById("theTree").currentIndex; print("selected " + index); } </script> <tree id="theTree" onselect="select()"> <treecols> <treecol label="First name" /> <treecol label="Last name" /> </treecols> <treechildren> <treeitem> <treerow> <treecell label="Bullock" /> <treecell label="Sandra" /> </treerow> </treeitem> <treeitem> <treerow> <treecell label="Roberts" /> <treecell label="Julia" /> </treerow> </treeitem> </treechildren> </tree> </window>
onchange
command on the tree
allows to listen to row content change events. For example:<window id="hello" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" > <script> function changed() { var column = document.getElementById("theTree").editingColumn; var row = document.getElementById("theTree").editingRow; print("change " + row + ", " + column); } </script> <tree id="theTree" onchange="change()"> <treecols> <treecol label="First name" /> <treecol label="Last name" /> </treecols> <treechildren> <treeitem> <treerow> <treecell label="Bullock" /> <treecell label="Sandra" /> </treerow> </treeitem> <treeitem> <treerow> <treecell label="Roberts" /> <treecell label="Julia" /> </treerow> </treeitem> </treechildren> </tree> </window>
treecell
elemt if you want to listen to a change event for a specific cell. For example:<window id="hello" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" > <script> function changed() { var label = document.getElementById("theCell").label; print("label changed " + label); } </script> <tree> <treecols> <treecol label="First name" /> <treecol label="Last name" /> </treecols> <treechildren> <treeitem> <treerow> <treecell label="Bullock" /> <treecell label="Sandra" /> </treerow> </treeitem> <treeitem> <treerow> <treecell id="theCell" label="Roberts" onchange="changed()"/> <treecell label="Julia" /> </treerow> </treeitem> </treechildren> </tree> </window>
<tree> <treecols> <treecol label="First name"/> <treecol label="Last name" /> </treecols> <treechildren> <treeitem> <treerow> <treecell label="Bullock" /> <treecell label="Sandra" /> </treerow> </treeitem> <treeitem> <treerow> <treecell label="Roberts" /> <treecell label="Julia" /> </treerow> </treeitem> <treeitem> <treerow> <treecell label="Johanson" /> <treecell label="Scarlett" /> </treerow> </treeitem> </treechildren> </tree>Result:
Copyright 2017-2020 Dassault Aviation. All Rights Reserved. Documentation and source under the LGPL v3 licence