Fast Tree selection.
Hi Alex,
Can you please suggest a faster way to select all leaf nodes for a specified parent node?
The code I have at the moment works correctly when the numbers are small, but when there is 1000 leaf nodes, this selection causes script timeouts.
<script type='text/javascript'>
var tree = {
0: [1, 2, 3, 4],
1: [5, 6],
2: [7],
3: [8],
4: [9]
}
var itemText = ["", "Node 1", "Node 2", "Node 3", "Node 4", "Node 5", "Node 6", "Node 7", "Node 8", "Node 9"];
var obj = new AW.UI.Tree;
obj.setItemText(itemText);
obj.setViewCount(function(i){return tree[i] ? tree[i].length : 0});
obj.setViewIndices(function(i){return tree[i]});
obj.setItemImage(["", "home", "favorites", "fontsize", "search", "search"]);
obj.setSize(300, 400);
obj.setSelectionMode("multi");
document.write(obj);
function select(parentIndex, selected)
{
var itemsToSelect = tree[parentIndex];
for (var i=0; i < itemsToSelect.length; i++)
{
obj.setItemSelected(selected, itemsToSelect[i]);
obj.setItemState((selected) ? 'selected' : '', itemsToSelect[i]);
}
}
</script>
Thanks again
Can you please suggest a faster way to select all leaf nodes for a specified parent node?
The code I have at the moment works correctly when the numbers are small, but when there is 1000 leaf nodes, this selection causes script timeouts.
<script type='text/javascript'>
var tree = {
0: [1, 2, 3, 4],
1: [5, 6],
2: [7],
3: [8],
4: [9]
}
var itemText = ["", "Node 1", "Node 2", "Node 3", "Node 4", "Node 5", "Node 6", "Node 7", "Node 8", "Node 9"];
var obj = new AW.UI.Tree;
obj.setItemText(itemText);
obj.setViewCount(function(i){return tree[i] ? tree[i].length : 0});
obj.setViewIndices(function(i){return tree[i]});
obj.setItemImage(["", "home", "favorites", "fontsize", "search", "search"]);
obj.setSize(300, 400);
obj.setSelectionMode("multi");
document.write(obj);
function select(parentIndex, selected)
{
var itemsToSelect = tree[parentIndex];
for (var i=0; i < itemsToSelect.length; i++)
{
obj.setItemSelected(selected, itemsToSelect[i]);
obj.setItemState((selected) ? 'selected' : '', itemsToSelect[i]);
}
}
</script>
Thanks again
Matt
September 26,