In your tree class, you can try to override the hasChildren method.
That method will return true if the parent has children.
If you want it to return true by any other means, override it and add what you need.
Hope that helps you.
Thank for your answer, indeed, i've already override hasChildren method and it works nice :
I have an element with a folder icon, but without children (they have been detected as parent element by my hasChildren overriden method).
So I can expand it (I see the expand icon).
When I try to expand it, I noticed that BeforeExpand is not fired (I need it to load the children).
And just after, my element is repainted and seems not to be detected as a parent (folder and expand icon disappear).
That's why I said "I understand now that BeforeExpand can not be fired if the element that trigger it has no child".
Add a Dummy Child to the tree node that needs future expansion
I had a similar problem - you don't get the expander on the tree node without a child. So on those nodes that I know need future expansion, I add a child node with the name field of Expanding... and have a hidden attribute in the tree store that indicates if the query has occurred yet (which is set on the node that needs expanding, not on the Expanding... node). Now I have an expander icon on the node in the tree. When I click the expander, the tree visually expands, showing the Expanding... node, then the BeforeExpand is fired. I look at the node queried field. If it is not set to true, I do the server query and mask the tree to prevent other operations. When the storeDataChanged method runs later, I remove the Expanding... child, replace it with the query results, and then unmask the tree.
Yes, I finally solved the problem excatly the same way.
But in my opinion there must/should be a better method to do it... Only the loading icon should be visible.
Tags for this Thread