Can a checkbox be included as a tree item

I need to have a tree where nodes have checkboxes in front(besides text) such that things can be checked or not checked per node.

thanks for any comments,
January 5,
Yes, this is possible but you have to make a new tree checkbox template class, which is derived from both AW.Tree.Item template and AW.Templates.Checkbox -

var MyTreeCheckbox = AW.Tree.Item.subclass();

MyTreeCheckbox.create = function(){

var treeValue = ["", true, false, "mixed", false, true, false];
var treeText = ["", "Home", "Favorites", "Font size", "Search", "Child1", "Child2"];
var treeImage = ["", "home", "favorites", "fontsize", "search"];
var treeView = {0:[1, 2, 3, 4], 1:[5, 6], 2:[7], 3:[8], 4:[9]};

var tree = new AW.UI.Tree;
tree.setItemTemplate(new MyTreeCheckbox);
tree.setViewCount(function(i){return treeView[i] ? treeView[i].length : 0});
tree.setViewIndices(function(i){return treeView[i]});

Checkbox template is linked to the item value property. You can also try CheckedItem template which works with selections (item selected property).
Alex (ActiveWidgets)
January 5,
Hi Alex,

Thanks for your comments...

Using the above suggestion how would we get the click events on the tree nodes?

Normally i would use this:
tree.onItemClicked = function(event, index){
alert("you clicked on the " + index + " leaf");

the above code stops working the moment we include this line: "tree.setItemTemplate(new MyTreeCheckbox);"

What event shoud we look for to know that the user clicked on a tree node?..

Thanks a lot!
January 30,
I've implemented the example shown above and it all seems to work nicely from the user's (cosmetic) perspenctive, but how do I determine which boxes are check (or not)?
Evan Ross
May 10,
September 12,

This topic is archived.

See also:

Back to support forum