1. #1
    Ext GWT Premium Member
    Join Date
    Jan 2009
    Location
    Colorado Springs, CO
    Posts
    325
    Vote Rating
    2
    DavidHoffer is on a distinguished road

      0  

    Question GXT 3.0 Tree - How to display custom icon per tree node?

    GXT 3.0 Tree - How to display custom icon per tree node?


    I need to display a multi-level tree and show various icons per tree node. In the demo examples all I see are images set at the root tree level, i.e. one TreeStyle for the entire tree. How can I display different icons at each of the tree nodes/levels?

  2. #2
    Ext GWT Premium Member
    Join Date
    Jun 2011
    Posts
    9
    Vote Rating
    0
    dierp is on a distinguished road

      0  

    Default


    Looks like you need to implement an IconProvider and pass it to the Tree.

  3. #3
    Sencha User
    Join Date
    Jul 2011
    Posts
    45
    Vote Rating
    0
    raivis is on a distinguished road

      0  

    Default


    Code:
            tree.setIconProvider(new IconProvider<SideMenuDto>() {
    
    
                @Override
                public ImageResource getIcon(SideMenuDto p_model) {
                    return  .... // your icon choosing algorithm
                }
            });
    where SideMenuDto is my tree item object. Use your own in your case.

  4. #4
    Ext GWT Premium Member
    Join Date
    Jan 2009
    Location
    Colorado Springs, CO
    Posts
    325
    Vote Rating
    2
    DavidHoffer is on a distinguished road

      0  

    Default


    Yeah that works perfectly, plus I found I can dynamically update the icons which is what I need to do by calling refresh on the tree. Thanks.