PDA

View Full Version : Set folder icon for empty directories in TreePanel



Cruiser
30 Nov 2010, 1:59 AM
How can i set a folder icon for a tree node which has no childrens? If i write this data for a TreePanel


children: [{
text: 'Menu Option 1',
leaf: true
}, {
text: 'Menu Option 2',
leaf: true
}, {
text: 'Menu Option 3',
leaf: false
}]

i will get for "Menu Option 1" and "Menu Option 2" a file icon and for "Menu Option 3" a Directory icon. But i will get a folder icon just for "Menu Option 3" even tough it has no children. Besides it should not show me this little expand Symbol on the left of the node.
Is this possible, or will i ever have this expand button on the left and have to click on it?

Thanks.

Condor
30 Nov 2010, 2:04 AM
Haven't tested, but you could try:

leaf: false,
loaded: true,
children: []

Cruiser
30 Nov 2010, 4:36 AM
Thanks for the fast reply, but that didn't work. I get the file icon anyway for this node.

Condor
30 Nov 2010, 4:47 AM
Maybe adding expandable:true helps...

Cruiser
30 Nov 2010, 8:37 AM
Maybe adding expandable:true helps...

That didn't helped also.
I solved it like this:
If i gave a node the attributes

{
text: 'Menu Option 1',
leaf: true
}
it looks like a file. So i add the attribute iconCls

{
text: 'Menu Option 1',
leaf: true,
iconCls: 'folder'
}
and created a CSS Class with the attribute !important


.folder{
background-image:url(ext-3.3.0/resources/images/default/tree/folder.gif) !important;
}

With this workaround it will overwrite the default image for the file node.
Not the best way maybe, but it works ;-)