I’m using a findItem command to search for an item in the Tree.
But now we want to search within a custom Attribute.
This way, we can find unique codes easily.
So in the XML we would have:
We would like to have the same behaviour as the findItem command.
Could this be implemented into dhtmlx tree?
Or is there an easier way to do this myself?
Hi
You need to iterate all the items and get this attribute: attr = tree.getAttribute(itemId, attribute);
Than you need to focus this item: tree.focusItem(attr);
Ah yes. But unfortunately the “unique”-code occurs more than once.
findItem find the next entity. Where the iteration would start over again.
So, the findItem is more advanced
I would have to write a similar function like findItem and that takes too much time.
There is no ready approach, but i can shoe you, how to iterate all the items you neeed:
function find1(){
var all = dhxTree.getAllSubItems(0);
var splited = all.split(',');
var id;
for (var i=0; i<splitted.length; i++){
id = splitted[i];
//put your search algorithm here
}
}
Recommend you to consider some of the next methods: getAllSubItems()
getAttribute()
getUserData()
getItemText()