--- title: currentIndex slug: Mozilla/Tech/XUL/Własność/currentIndex tags: - Własności_XUL translation_of: Archive/Mozilla/XUL/Property/currentIndex ---
« Dokumentacja XUL
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 obiektu nsITreeSelection dostępnego przez tree.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>