3.2.0

How do I create treeview with checkbox and radiobutton

I want to create a treeview with checkbox, image and radiobutton. How can I do?
John
March 6,
You should create your custom tree item template, for example, this one is a subclass of the standard tree item but it also adds checkbox code -

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

MyTreeCheckbox.create = function(){
    AW.Templates.Checkbox.create.call(this);
}


Here is a complete example -

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

MyTreeCheckbox.create = function(){
    AW.Templates.Checkbox.create.call(this);
}

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.setItemValue(treeValue);
tree.setItemText(treeText);
tree.setItemImage(treeImage);
tree.setViewCount(function(i){return treeView[i] ? treeView[i].length : 0});
tree.setViewIndices(function(i){return treeView[i]});
document.write(tree);

tree.onItemMouseDown = function(event, i){
    window.status = "item mouse down: " + i;
}

tree.onItemClicked = function(event, i){
    // BUG: onItemClicked event does not fire
}

tree.onItemValueChanged = function(value, i){
    window.status = "checkbox value changed to: " + value + " " + i;
}
Alex (ActiveWidgets)
March 6,

Thanks Alex, It's working, but onItemClicked event isn't working ah!

John
John
March 7,

This topic is archived.

See also:


Back to support forum