views:

2503

answers:

3

I have a setup where the tab is expected to be loaded based on user selection of an item from a left panel tree. My objective is to load only the relevant items as per the user selection to a particular tab.

The first time, I am able to add item as below:

    var tab = tabs1.getItem('Orders');   
    tab.remove(0);
    tab.add(pane33);
    tab.doLayout(); 

But, when the user selects the item again, the panel item is already removed, and errors out as (c.getPositionEl().dom is undefined).

The error is due to the item being removed or destroyed. There seems no option to replace the tab item, or to refresh/reload panels.

How to handle this?

Thanks.

A: 

you can mark that selection as 'selected' and check at mouse actions. as a simple approach.

Halo
Please clarify your suggestion.
Natkeeran
keeping an array of boolean variables, you know, that has the size of your tree. so when an action happens if your item was already selected before, you don't execute that load operation.
Halo
+1  A: 

Container.remove has an optional second argument autoDestroy, which means the component being removed is also destroyed permanently (for TabPanels, this defaults to true). You are only instantiating your child components one time, so after they get destroyed they are no longer available to be added. Either pass autoDestroy: false (this can be set at the TabPanel level as well) and hide existing components after removing them (then simply show them on subsequent clicks), or you'll have to reinstantiate them before adding each time.

bmoeskau
You suggestion is close, but the issue remains. Because, when I need to only show a particular panel at any one time, and tab.hide() hides the all the panels, and but I can't find a way to only show selected panels or grids. For instance, tab.show(ProductTypesEditorGrid); shows all the hidden panels.
Natkeeran
You can show/hide components directly, like editorGrid.show() if you have a reference, or Ext.getCmp('component-id').show()
bmoeskau
A: 

bmoeskau: You saved my life! Thank you very much!

Mus