Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-2706

Tabs are not added at the correct index

XMLWordPrintable

      When using a Tabbox with a ListModel and adding a new object to the model, the corresponding tab is always added at the end, regardless of the position of the object in the model. The order of the tabs can be corrected by throwing an ContentsChanged or StructureChanged event, but this will cause the tabbox to reinitialize ALL tabs (like when using children binding). Since we are using fulfill to lazily initialize our (expensive) tabpanels, this wastes quite some time.

      I investigated a bit further and found a solution in TabboxEngineImpl.Renderer.render:

       
      private void render(Tabbox tabbox, Object value, int index) throws Throwable { 
      ... 
      tabbox.getTabs().appendChild(tab); 
      ... 
      tabbox.getTabpanels().appendChild(tabpanel); 
      ... 
      } 
      

      The Renderer completely ignores the index. I copied the TabboxEngineImpl and changed those two lines to:

       
      private void render(Tabbox tabbox, Object value, int index) throws Throwable { 
      ... 
      tabbox.getTabs().insertBefore(tab, 
          tabbox.getTabs().getChildren().size() == index ? null : 
              tabbox.getTabs().getChildren().get(index)); 
      ... 
      tabbox.getTabPanels().insertBefore(tabpanel, 
          tabbox.getTabPanels().getChildren().size() == index ? null : 
              tabbox.getTabPanels().getChildren().get(index)); 
      ... 
      } 
      

      Now the tabs are added at the intended position.

            SEFI SEFI
            Guido2406 Guido2406
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: