extjs - How to check whether xtype object exists or not in extjs4.1 -


i getting object using ext.component.query. need check whether object exists or not. if object exists, need remove object. can tell me how this?

thanks

as other posters have mentioned, method you're looking ext.componentquery, returns array can check length of via length, in turn tell if object exists or not. if object exists, can destroyed via destroy() method of ext.abstractcomponent

i have made jsfiddle example demonstrating you're trying here: http://jsfiddle.net/mpypw/

code fiddle:

ext.create('ext.panel.panel', {     name : 'mypanel',     title: 'panel 1',     width: 200,     html: '<b>its panel!</b>',     renderto: ext.getbody() });  ext.create('ext.panel.panel', {     name : 'mypanel',     title: 'panel 2',     width: 200,     html: 'look, panel!',     renderto: ext.getbody(),     dockeditems: [{     xtype: 'toolbar',     dock : 'bottom',     items: [{         text: 'destroy panels!',         handler: function(){             // here can query panels             var panels = ext.componentquery.query('panel[name=mypanel]'),                  trees = ext.componentquery.query('treepanel');              // @param {ext.panel.panel[]} panels array of panel components             if(panels.length > 0){                 alert("about destroy " + panels.length + " panels!");                 ext.each(panels, function(panel){                     panel.destroy();                 });             }              // there no tree panels             if(!trees.length){                 alert("there no tree panels destroy!");             }         }     }]     }] }); 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -