简体   繁体   中英

How to destroy a Panel in extjs

I have a border layout in which west side have few buttons. On click of buttons few panels will show in central panel. Here is example code of the one panel which display in central panel.

{
    xtype: 'myPanel', //  User define panel
    itemId: 'myPanel1',
    showZoom: false,
    showLegends:false,
    showSlider: false,
    showDataGrid: true,
    chartType: 'line',
    controlPanel:false,
    orientation: 'x'
}

Now I have one buton called setting which open one window. Window having some checkboxes. In that I have one checkbox called Legends. I want when I click on checkbox legends then from above panel showLegends : true.When showLegends is true it will create a legendpanel and on false i want to destroy that panel.

ShowLegends:true

 if (me.showLegends) {
 legendPanel = Ext.create('Igo.panel.LegendsPanel', {
     itemId: graphConfig.itemId + 'legends',
     graphId: graphConfig.itemId
 });
 }
 cPanel.add(gPanel);

How can i destroy this panel when Showlegends is false.Please help by answering this!!

Hope this helps, Ext.getCmp(id) gives you the object with a known id, in your case myPanel1

if (me.showLegends) {
  legendPanel = Ext.create('Igo.panel.LegendsPanel', {
  itemId: graphConfig.itemId + 'legends',
  graphId: graphConfig.itemId
  });
}else{
  Ext.getCmp("myPanel1").destroy()
}

 if (me.showLegends) { legendPanel = Ext.create('Igo.panel.LegendsPanel', { itemId: graphConfig.itemId + 'legends', graphId: graphConfig.itemId }); } else { if(legendPanel) parentnode.remove(legendPanel,true); //ParentNode is parent component of legentPanel, second argument oprional. } 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM