XUL:Property:currentIndex
From MDC
« XUL Reference home
- currentIndex
- Type: integer
- Set to the index of the currently focused row in the tree. If no row is focused, the value will be
-1. For multiple selection trees, the current index is the last row selected. Do not use this property to change the selection. Instead, use the methods of the nsITreeSelection object available via tree.view.selection.
// One way of retrieving the text of a cell.
<script language ="javascript">
function treeRowClicked(){
var tree = document.getElementById("my-tree");
var selection = tree.view.selection;
var cellText = tree.view.getCellText(tree.currentIndex, tree.columns.getColumnAt(0));
alert(cellText);
}
</script>
<tree id="my-tree" seltype="single" onselect="treeRowClicked()">
<treecols>
<treecol label="Title" flex="1"/><treecol label="URL" flex="1"/>
</treecols>
<treechildren>
<treeitem>
<treerow>
<treecell label="joe@somewhere.com"/>
<treecell label="Top secret plans"/>
</treerow>
</treeitem>
<treeitem>
<treerow>
<treecell label="mel@whereever.com"/>
<treecell label="Let's do lunch"/>
</treerow>
</treeitem>
</treechildren>
</tree>