Hybrid View

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

      0  

    Default Unanswered: Tree - more that one icon for leaf/folder cells

    Unanswered: Tree - more that one icon for leaf/folder cells


    Hello all!

    I was wondering how can one set more than one leaf/folder icon for the Tree widget in gxt v3? The only way I've found out is by overriding cells render method:
    Code:
    SimpleSafeHtmlCell<String> cell = new SimpleSafeHtmlCell<String>(
            SimpleSafeHtmlRenderer.getInstance(), "") {
    
    
        @Override
        public void render(Context context, String data, SafeHtmlBuilder sb) {
            if (data.equals("Beethoven")) {                    
                tree.getStyle().setNodeCloseIcon(Resources.IMAGES.myimage1());
                tree.getStyle().setNodeOpenIcon(Resources.IMAGES.myimage1());
            } else {
                tree.getStyle().setNodeCloseIcon(Resources.IMAGES.myimage2());
                tree.getStyle().setNodeOpenIcon(Resources.IMAGES.myimage2());
            }
            super.render(context, data, sb);
        }                                
    };
    But somehow I doubt that's the best way. In Senchas gxt demo explorer you can see, that they are using more than one icon for leaves (open some UI Binder example and switch to source tab. You can see different icons for different file types in a file tree), but there are no examples on achieving this.

    p.s. This is definitively not the correct way to do this, because it does not behave like I suspected. Another way of doing it is to append the icon to SafeHtmlBuilder in render method, but still, not sure that's the way it should be.
    Last edited by raivis; 25 Nov 2011 at 1:36 AM. Reason: src code is not doing what I suspected it would

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

      0  

    Default


    As I am new to all this stuff, it took me a while to figure that out. If I have understood it right, you have to make your own TreeAppearance class (base one BlueTreeAppearance can be extended as well). Most likely several of them to support all the base themes (currently blue and gray).

    edit
    I still don't know what would be the best solution overall, but I found out that in my case that would be by overriding Tree's method:

    protected ImageResource calculateIconStyle(M model)
    Last edited by raivis; 28 Nov 2011 at 2:36 AM. Reason: found better solution

  3. #3
    Sencha User
    Join Date
    Sep 2011
    Location
    Angers, France
    Posts
    6
    Vote Rating
    1
    pgy49 is on a distinguished road

      0  

    Default


    Use
    Code:
    tree.setIconProvider(IconProvider)
    with your own implementation of IconProvider you can set a different icon depending on your data.

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

      0  

    Default


    will try it out, ty

Thread Participants: 1

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar