Q:

Showing same panel in a window and tabpanel ExtJs

I have a panel inside a tabpanel and when a button is pressed i want to show that panel inside a full screen window. here is what i am doing now:
 var panel = Ext.ComponentQuery.query('apanel')[0];
     if(button.pressed){
          if(Ext.getCmp('awindow')){ //if the window already exists
                Ext.getCmp('awindow').items.add(panel).show();// add the item to it
          } else{ // create a new window with the element
            Ext.create('Ext.window.Window', {
                title: 'Model Selector',
                layout: 'fit',
                id: 'apanel',
                contentEl: panel.getId(),
                maximized: true
            }).show();
        }
    }  else {
        Ext.getCmp('apanel').close(); // close the window
        Ext.ComponentQuery.query('maintabpanel')[0].updateLayout(); // update layout
    }

But it is giving me this error :

Failed to execute 'insertBefore' on 'Node': parameter 1 is not of type
  'Node'.

what should i do so that the same panel is shown in tab panel when i close the window?

A:

The .close() method on window was causing the problem so i use the .hide() on window instead.
if(button.pressed){
          if(Ext.getCmp('awindow')){ //if the window already exists
                Ext.getCmp('awindow').items.add(panel).show();// add the item to it
                Ext.getCmp('awindow').show()
          } else{ // create a new window with the element
            Ext.create('Ext.window.Window', {
                title: 'Model Selector',
                layout: 'fit',
                id: 'apanel',
                contentEl: panel.getId(),
                maximized: true
            }).show();
        }
    }  else {
        Ext.getCmp('apanel').hide(); // close the window
        Ext.ComponentQuery.query('maintabpanel')[0].updateLayout(); // update layout
    }

