Numbering parents and children

I was wondering if it is possible to number all parents and children in a tree as an option. I would like the tree to look something like this:

1 - This is the first parent
1.1 - This is the first child
1.1.1 - Another child
1.2 - The second child of parent 1
2 - Parent number 2
3 - Paren number 3
3.1 - Child 1 belonging to parent 3
etc.

If I move a child or parent via code or drag and drop I would like the numbers to adjust automatically. Is this possible?

Thanks

unfortunately such feature is not available.

Would it be possible to do something with css? In css there is a counter function to autonumber elements. I’m wondering if this can be used for the tree as well?
Have a look at listing 9 on the following page: http://www.css-zibaldone.com/articles/counters/csscounters.html

Thanks in advance.

I’m wondering if this can be used for the tree as well?

Nope.

Tree supports setItemText method. You may place the text label into item userdata. And when data are loaded, you may get all items loop through them, check their level and index and then set new label. For example:

[code]
tree.loadXML(url,function(){
var items = tree.getAllSubItems(0).split(",");
for(var i=0; i< items.length;i++){
var id =items[i];
setItemName(id);
}
})

function setItemName(id){
var level = tree.getLevel(id)-1;
var prefix = “”;
while(level){
prefix += level+".";
level–;
}
var index = tree.getIndexById(id)+1;
prefix += index;
tree.setItemText(id,prefix+" "+tree.getUserData(id,“name”))
}[/code]

If I move a child or parent via code or drag and drop I would like the numbers to adjust automatically.

You may execute the same approach from onDrop event handler.

Thanks Alexandra for your reply. Looks interesting. I will try what you suggested.