[CLOSED] Tree Panel with out using leaf=true

  1. #1

    [CLOSED] Tree Panel with out using leaf=true

    Hi,

    Generally any tree panel will check by its own with out setting any property, but in Ext.Net tree panel need to use leaf=true.

    Is there any option with setting the property leaf=true.

    If there is no child node then it should not display "+" in tree panel.

    Thank you,
    Vamsi.
    Last edited by fabricio.murta; Aug 28, 2019 at 9:14 PM.
  2. #2
    Hello @Vamsi!

    What you suggest makes sense, but some might think of the nodes as "folders", so "by default" they are "empty folders".

    And in fact, as you noticed, it is by default a folder (allows children and gets the expander icon rendered) according to Ext JS documentation.

    This is not something you can just override with the TreePanel's Defaults setting unfortunately, and I couldn't find an easy way to override it. It seems that was written intended to be specified as leaf, always.

    If you really want to skip specifying the setting, you can "flatten" the tree after you define it by changing (for example) this in your page:

    - Add this function to "flatten" nodes without children:
    function flatten(items) {
        Ext.Array.forEach(items, function (item) {
            if (item.childNodes.length > 0) {
                flatten(item.childNodes);
            } else {
                item.set('leaf', true);
            }
        });
    }
    - Bind the BeforeRender event to flatten the current store's entries, by adding this within the tree panel's Listeners block:
    <BeforeRender Handler="flatten(this.getStore().getData().items)" />
    Hope this helps!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Thank you. Working as expected using above solution.
  4. #4
    Hello @Vamsi!

    Glad the solution was acceptable, thanks for the feedback!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. Replies: 6
    Last Post: Jan 08, 2017, 5:58 PM
  2. [CLOSED] Drag and drop from tree panel to tree panel.
    By Prasoon in forum 2.x Premium Help
    Replies: 1
    Last Post: Dec 23, 2015, 5:57 PM
  3. [CLOSED] Not able to drag drop leaf to leaf in TreeGrid
    By legaldiscovery in forum 1.x Premium Help
    Replies: 1
    Last Post: Aug 15, 2011, 1:47 PM
  4. Tree Node leaf
    By Richardt in forum 1.x Help
    Replies: 3
    Last Post: Sep 24, 2009, 11:06 AM
  5. [CLOSED] Error when deleting a tree leaf
    By Sharon in forum 1.x Premium Help
    Replies: 2
    Last Post: Jan 21, 2009, 11:12 AM

Posting Permissions