XUL:Własność:currentIndex
z Mozilla Developer Center, polskiego centrum programistów Mozilli.
- currentIndex
- Typ: integer
- Ustawia indeks bieżącego aktywnego wiersza w tree (drzewie). Jeśli jest brak aktywnego wiersza, wartość będzie
-1. Dla wielu zaznaczeń drzew, bieżącym indeksem jest ostatnio zaznaczony wiersz. Nie stosuj tej własności do zmiany zaznaczenia. Zamiast stosować metody obiektunsITreeSelectiondostępnego przeztree.view.selection.
// One way of retrieving the text of a cell.
<script language ="javascript">
function treeRowClicked(){
var tree = Id("my-tree");
var selection = tree.contentView.getItemAtIndex( tree.currentIndex );
var foo = selection.firstChild.firstChild.getAttribute("label");
alert(foo);
}
</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="Ściśle tajne plany"/>
</treerow>
</treeitem>
<treeitem>
<treerow>
<treecell label="mel@whereever.com"/>
<treecell label="Zróbmy obiad"/>
</treerow>
</treeitem>
</treechildren>
</tree>