Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Cannot display icon on dynamically displaying tab...

    SmartGWT version: v8.2p_2012-10-31/Pro Deployment (built 2012-10-31)

    I have a tab in my application that hides or shows depending upon a condition. I also want to display an icon on this dynamic tab at times. However, I cannot seem to get this working. I've included some sample code that basically describes what I'm doing.

    Note that, for the tabs that are permanent, I can display the icon just fine.

    Any help would be greatly appreciated. Let me know if you have questions or need further information.

    James

    Code:
    private TabSet tabs;
    
    public void makeTabSet() {
       tabs = new TabSet();
       tabs.addTab(createTab("A", /* make A's panel */ ), 0);
       tabs.addTab(createTab("B", /* make B's panel */ ), 1);
       tabs.addTab(createTab("C", /* make C's panel */ ), 2);
    }
    
    private Tab createTab(String title, Canvas pane) {
       Tab t = new Tab(title);
       t.setID(title);
       t.setPane(pane);
       return t;
    }
    
    private void hideDynamicTab() {
       Tab t = tabs.getTab("B");
       tabs.updateTab(t, null);
       tabs.removeTab(t);
    }
    
    private void showDynamicTab() {
       Tab t = tabs.getTab("B");
       if (t == null) {
          tabs.addTab(createTab("B", /* make B's panel */ ), 1);
       }
    }
    
    private void showIconOnDynamicTab() {
       Tab t = tabs.getTab("B");
       t.setIcon("path/to/icon.png");
    }
    
    private void hideIconOnDynamicTab() {
       Tab t = tabs.getTab("B");
       t.setIcon(null);
    }

    #2
    Have an additional icon when a tab is closable currently requires adding the icon as HTML in the Tab's title - see this thread.

    Comment


      #3
      OK, I've made the following change to my code based on the suggestion in the other thread, but it still doesn't work:

      Code:
      private void showIconOnDynamicTab() {
         Tab t = tabs.getTab("B");
         t.setTitle("<span>" + Canvas.imgHTML("/path/to/icon.png") + " B</span>");
         // t.setIcon("path/to/icon.png");
      }
      
      private void hideIconOnDynamicTab() {
         Tab t = tabs.getTab("B");
         t.setTitle("B");
         // t.setIcon(null);
      }

      Comment


        #4
        Can you elaborate on "doesn't work"?

        Comment


          #5
          The icon does not display.

          Comment


            #6
            tabSet.setTabTitle() is the appropriate way to change a tab's title after draw.

            Comment


              #7
              tabSet.setTabTitle(...) did the trick! Thank you!

              Comment

              Working...
              X