Hello, I am evaluating the standard version of tree. When I left click on a node in my tree, the onSelect function is being called and the proper id is passed to it, but the node is not highlighting in the tree (no background color). I have tried setting enableHilighting(true), but it makes no difference. Here is my code, can you tell me what I am doing wrong?
Thank you, Dan
function myClick2 (id) {
this.focusItem(id);
new Ajax.Request(’/vm/snap_pressed/’ + this.getSelectedItemText() + ‘?pressed=vm_test’,
{asynchronous:true, evalScripts:true,
onComplete:function(request){miqSparkle(false);},
onLoading:function(request){miqSparkle(true);}}
);
}
tree2=new dhtmlXTreeObject(“treebox”,“100%”,“100%”,0);
tree2.setImagePath("/javascripts/dhtmlx/imgs/");
tree2.insertNewChild(0,1,“EvmSnapshot (Active)”,0,“globe.gif”,“globe.gif”,“globe.gif”,“SELECT,TOP,CHILD”)
tree2.insertNewChild(1,2,“Snap 2”,0,“globe.gif”,“globe.gif”,“globe.gif”,“CHILD”)
tree2.insertNewChild(2,3,“Snap 2-1”,0,“globe.gif”,“globe.gif”,“globe.gif”)
tree2.insertNewChild(1,4,“Snap 3”,0,“globe.gif”,“globe.gif”,“globe.gif”,“CHILD”)
tree2.insertNewChild(4,5,“Snap 3-1”,0,“globe.gif”,“globe.gif”,“globe.gif”)
tree2.insertNewChild(4,6,“Snap 3-2”,“globe.gif”,“globe.gif”,“globe.gif”)
tree2.enableHighlighting(true);
// enable/disable tree lines
tree2.enableTreeLines(true);
// set plus images
tree2.setImageArrays(“plus3.gif”,“plus2.gif”,“plus4.gif”,“plus.gif”,“open2.gif”);
//set minus images
tree2.setImageArrays(“minus3.gif”,“minus2.gif”,“minus4.gif”,“minus.gif”,“close2.gif”);
//set default node images
tree2.setStdImages(“books.gif”,“books_open.gif”,“books_close.gif”);
//set onselect event
tree2.attachEvent(“onSelect”,myClick2)
onSelect event is blockable, so value which you returns from custom event handler has sense
true - select operation confirmed
false, or none - select operation blocked
To resolve issue just add return true; instruction to your code
function myClick2 (id) {
this.focusItem(id);
new Ajax.Request(’/vm/snap_pressed/’ + this.getSelectedItemText() + ‘?pressed=vm_test’,
{asynchronous:true, evalScripts:true,
onComplete:function(request){miqSparkle(false);},
onLoading:function(request){miqSparkle(true);}}
);
return true;
}
Thank you for the response, however, the highlighting of the selected field was not working before I added the onSelect event handler. I added that to make sure the item was actually being selected because I couldn’t tell on the screen. Sure enough, the function is being called because I see the ajax method being run on the server and I update the screen with a response. So, after adding return true; to my function, it still doesn’t highlight the selected node. Any other ideas?
Thanks, Dan
Please, be sure that dhtmlxtree.css file is included correctly.
If problem persists, please, provide sample where it can be reconstructed to support@dhtmlx.com
It was the missing CSS, now it works perfectly . . . Thanks!