:: Forum >>

Problem with selectedItem in Tree

Hi,

I realized a tree which contains objects. Objects are composed of Label and Link. I want when I click on an item that link's Image appear, and all others disappear. In the following code (a bit long but directly available), I have the previous Item selected which stay appear. It seems that a sub function is launched but I don't know what it is.

var name1 = new AW.UI.Label; name1.setControlText('dossier');
var addFile1 = new AW.UI.Link; addFile1.setControlImage('search');
addFile1.setControlText(''); addFile1.setControlTooltip('Add File');
addFile1.onControlClicked = function(event){alert('addFile1');};
var addFolder1 = new AW.UI.Link; addFolder1.setControlImage('favorites');
addFolder1.setControlLink(''); addFolder1.setControlTooltip('Add Folder');
addFolder1.onControlClicked = function(event){alert('addFolder1');};
var delete1 = new AW.UI.Link; delete1.setControlImage('fontsize');
delete1.setControlLink(''); delete1.setControlTooltip('Delete');
delete1.onControlClicked = function(event){alert('delete1');};
var obj1 = name1 + addFile1 + addFolder1 + delete1;

var name2 = new AW.UI.Label; name2.setControlText('test dossier');
var addFile2 = new AW.UI.Link; addFile2.setControlImage('search');
addFile2.setControlText(''); addFile2.setControlTooltip('Add File');
addFile2.onControlClicked = function(event){alert('addFile2');};
var addFolder2 = new AW.UI.Link; addFolder2.setControlImage('favorites');
addFolder2.setControlLink(''); addFolder2.setControlTooltip('Add Folder');
addFolder2.onControlClicked = function(event){alert('addFolder2');};
var delete2 = new AW.UI.Link; delete2.setControlImage('fontsize');
delete2.setControlLink(''); delete2.setControlTooltip('Delete');
delete2.onControlClicked = function(event){alert('delete2');};
var obj2 = name2 + addFile2 + addFolder2 + delete2;

var name3 = new AW.UI.Label; name3.setControlText('test doc.txt (HEAD)');
var view3 = new AW.UI.Link; view3.setControlImage('search');
view3.setControlLink(''); view3.setControlTooltip('View');
view3.onControlClicked = function(event){alert('view3');};
var modify3 = new AW.UI.Link; modify3.setControlImage('favorites');
modify3.setControlLink(''); modify3.setControlTooltip('Update');
modify3.onControlClicked = function(event){alert('update3');};
var delete3 = new AW.UI.Link; delete3.setControlImage('fontsize');
delete3.setControlLink(''); delete3.setControlTooltip('Delete');
delete3.onControlClicked = function(event){alert('delete3');};
var obj3 = name3 + view3 + modify3 + delete3;

var name4 = new AW.UI.Label; name4.setControlText('Revision 12');
var view4 = new AW.UI.Link; view4.setControlImage('search');
view4.setControlTooltip('View'); view4.setControlLink('');
view4.onControlClicked = function(event){alert('view4');};
var revert4 = new AW.UI.Link; revert4.setControlImage('favorites');
revert4.setControlLink(''); revert4.setControlTooltip('Revert');
revert4.onControlClicked = function(event){alert('revert4');};
var obj4 = name4 + view4 + revert4;

var name5 = new AW.UI.Label; name5.setControlText('param.txt (HEAD)');
var view5 = new AW.UI.Link; view5.setControlImage('search');
view5.setControlLink(''); view5.setControlTooltip('View');
view5.onControlClicked = function(event){alert('view5');};
var modify5 = new AW.UI.Link; modify5.setControlImage('favorites');
modify5.setControlLink(''); modify5.setControlTooltip('Update');
modify5.onControlClicked = function(event){alert('modify5');};
var delete5 = new AW.UI.Link; delete5.setControlImage('fontsize');
delete5.setControlLink(''); delete5.setControlTooltip('Delete');
delete5.onControlClicked = function(event){alert('delete5');};
var obj5 = name5 + view5 + modify5 + delete5;

var name6 = new AW.UI.Label; name6.setControlText('Revision 11');
var view6 = new AW.UI.Link; view6.setControlImage('search');
view6.setControlTooltip('View'); view6.setControlLink('');
view6.onControlClicked = function(event){alert('view6');};
var revert6 = new AW.UI.Link; revert6.setControlImage('favorites');
revert6.setControlLink(''); revert6.setControlTooltip('Revert');
revert6.onControlClicked = function(event){alert('revert6');};
var obj6 = name6 + view6 + revert6;

var name7 = new AW.UI.Label; name7.setControlText('hello.php (HEAD)');
var view7 = new AW.UI.Link; view7.setControlImage('search');
view7.setControlLink(''); view7.setControlTooltip('View');
view7.onControlClicked = function(event){alert('view7');};
var modify7 = new AW.UI.Link; modify7.setControlImage('favorites');
modify7.setControlLink(''); modify7.setControlTooltip('Update');
modify7.onControlClicked = function(event){alert('modify7');};
var delete7 = new AW.UI.Link; delete7.setControlImage('fontsize');
delete7.setControlLink(''); delete7.setControlTooltip('Delete');
delete7.onControlClicked = function(event){alert('delete7');};
var obj7 = name7 + view7 + modify7 + delete7;

var name8 = new AW.UI.Label; name8.setControlText('Revision 3');
var view8 = new AW.UI.Link; view8.setControlImage('search');
view8.setControlTooltip('View'); view8.setControlLink('');
view8.onControlClicked = function(event){alert('view8');};
var revert8 = new AW.UI.Link; revert8.setControlImage('favorites');
revert8.setControlLink(''); revert8.setControlTooltip('Revert');
revert8.onControlClicked = function(event){alert('revert8');};
var obj8 = name8 + view8 + revert8;

var name9 = new AW.UI.Label;
name9.setControlText('Revision 1');
var view9 = new AW.UI.Link; view9.setControlImage('search');
view9.setControlTooltip('View'); view9.setControlLink('');
view9.onControlClicked = function(event){alert('view9');};
var revert9 = new AW.UI.Link; revert9.setControlImage('favorites');
revert9.setControlLink(''); revert9.setControlTooltip('Revert');
revert9.onControlClicked = function(event){alert('revert9');};
var obj9 = name9 + view9 + revert9;

function displayObject(style, number){
    var data ="";
    var type = tree.getItemImage(number);
    switch (type){
        case("home"):
            //alert(tree.getItemText(number));
            data += "addFile"+number+".setStyle('display','"+style+"');addFolder"+number+".setStyle('display','"+style+"');delete"+number+".setStyle('display','"+style+"');";
            data += "obj"+number+" = name"+number+" + addFile"+number+" + addFolder"+number+" + delete"+number+";";
            break;
        case("fontsize"):
            //alert(tree.getItemText(number));
            data += "view"+number+".setStyle('display','"+style+"');modify"+number+".setStyle('display','"+style+"');delete"+number+".setStyle('display','"+style+"');";
            data += "obj"+number+" = name"+number+" + view"+number+" + modify"+number+" + delete"+number+";";
            break;
        default:
            data += "view"+number+".setStyle('display','"+style+"');revert"+number+".setStyle('display','"+style+"');";
            data += "obj"+number+" = name"+number+" + view"+number+" + revert"+number+";";
            break;
    }
    //alert(data);
    eval(data);
}


function displayAllObject(except){
    var last = 9;
    for (i=1; i<=last; i++){
         if (i!=except)
            displayObject("none", i);
    }
}

var tree = new AW.UI.Tree;
var treeView = {
0: [1, 5, 7],
1: [2],
2: [3],
3: [4],
5: [6],
    7: [8,9]
}

var treeImage =
//tree.setStyle("height: 30px");
tree.setItemText(["",obj1,obj2,obj3,obj4,obj5,obj6,obj7,obj8,obj9]);
tree.setItemImage(['','home','home','fontsize','','fontsize','','fontsize','','']);
tree.setViewCount(function(i){return treeView[i] ? treeView[i].length : 0});
tree.setViewIndices(function(i){return treeView[i]});
    
tree.onItemClicked = function (event, index){
        displayAllObject(index);
    }
        
    tree.onTreeSignClicked = function (event, index){
        tree.setSelectedItems('');
        tree.setViewExpanded(!tree.getViewExpanded(index), index);
        displayAllObject(0);
    }
        

document.write(tree);
    
    displayAllObject(0);


I hope you can find the problem.
Caplain G.
Monday, August 4, 2008
up any idea?
Caplain G.
Friday, August 8, 2008

This topic is archived.


Back to support forum

Forum search