PDA

View Full Version : [SOLVE][FAQ][TREE][UI]root degenerate to a leaf



redlz2500
27 Apr 2008, 12:51 AM
a treepanel with a tree loader
when a node be clicked, the server will send the sons of the node
but, if server return nothing (means [{}] or else...)
the node will degenerate to a leaf

please tell me how to avoid this? if node is a leaf, i will set it, i needn't the autowork~
i think there should have some para to do this
or should i add event to reset the node?

redlz2500
27 Apr 2008, 1:42 AM
by track the code
i find the UI change function:
i think which is in:Ext.tree.TreeNodeUI.prototype->updateExpandIcon
it whill

replaceClass("x-tree-node-expanded", "x-tree-node-leaf")
but i am confuse to avoid the autowork....
please lead me to solve the question

Animal
27 Apr 2008, 3:20 AM
This is in the FAQ

redlz2500
27 Apr 2008, 3:54 AM
emmm, it is my fault ignor FAQ
but i find it still doesn't work

the server code as this:

while($row=mysql_fetch_array($rs)){
$res[]=array('id'=>$row['id'],'text'=>$row['name'],'iconCls'=>"folder");
}
echo(json_encode($res));
and my simple tree code is here:

var mytree=new Ext.tree.TreePanel({
el:'the-tree',
animate:true,
autoScroll:true,
loader:new Ext.tree.TreeLoader({
dataUrl:'server/get-node.php',
})
});
var tn=new Ext.tree.AsyncTreeNode({
text:'ROOT',
id:'0',
expanded:true,
iconCls: "folder"
});
mytree.setRootNode(tn);
mytree.render();
please tell me more....

Animal
27 Apr 2008, 4:23 AM
You have to add your own CSS rule to style a node with that class to display the image you want it to.

redlz2500
27 Apr 2008, 5:06 AM
yes ,you are right
i just see the js code
but didn't see the css eg

please forgive me

at last before read your last reply, i find my fault yet
and change my css file follow the faq

so, i know my question, especially after you answer , is so foolish
i wish you could still give me help in the coming days

thanks for you give me help with patience
:D

Animal
27 Apr 2008, 6:05 AM
Don't worry. I'll try to keep you on the righ track when I can!