简体   繁体   English

如何在extjs中销毁面板

[英]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。当showLegends为true时,它将创建一个Legendpanel面板,如果为false,则我想破坏该面板。

ShowLegends:true ShowLegends:真

 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!! 如果Showlegends为假,我如何销毁该面板。请回答此问题!

Hope this helps, Ext.getCmp(id) gives you the object with a known id, in your case myPanel1 希望这会有所帮助,Ext.getCmp(id)为您提供具有已知id的对象,在您的情况下为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. } 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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