最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Adding an Ext.Button class into a Box Component - Stack Overflow

programmeradmin1浏览0评论

I'm working with extjs 2.2.1, having a bit of a trouble adding a button into a box ponent class. From my understanding, because box ponent extends the ponent class, it has no config options that allow an item to be added. So the code below does not work...

new Ext.Viewport({
   layout : 'border',
   items : [new Ext.BoxComponent({
      region : 'north',
      el : 'north',
      height : 50,
      items : new Ext.Button({
         iconCls : 'logout',
         text : 'logout',
         tooltip : 'logout',
         handler : function() { }
      }, mainTabPanel])
});

Is there a workaround where I can can add a button into this northern region that is made up of a boxponent class? Any help in the right direction is greatly appreciated. Thank you.

I'm working with extjs 2.2.1, having a bit of a trouble adding a button into a box ponent class. From my understanding, because box ponent extends the ponent class, it has no config options that allow an item to be added. So the code below does not work...

new Ext.Viewport({
   layout : 'border',
   items : [new Ext.BoxComponent({
      region : 'north',
      el : 'north',
      height : 50,
      items : new Ext.Button({
         iconCls : 'logout',
         text : 'logout',
         tooltip : 'logout',
         handler : function() { }
      }, mainTabPanel])
});

Is there a workaround where I can can add a button into this northern region that is made up of a boxponent class? Any help in the right direction is greatly appreciated. Thank you.

Share Improve this question edited Sep 12, 2009 at 2:31 Wouter van Nifterick 24.1k7 gold badges81 silver badges123 bronze badges asked Jul 27, 2009 at 23:53 SnowrightSnowright 6254 gold badges15 silver badges22 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

BoxComponent doesn't have the ability to contain child items, if you look at the docs you'll see there isn't a configuration option to do that. You will need to use a Container (or some subclass thereof) to get this effect.

There was no way around having child items in a BoxComponent class as it is not a container. so instead, I changed the BoxComponent to a container class, like Panel, that allowed me to add a button class.

new Ext.Viewport({
   layout : 'border',
   items : [new Ext.Panel({
      region : 'north',
      applyTo : 'north',
      height : 50,
      items : new Ext.Button({
         iconCls : 'logout',
         text : 'logout',
         tooltip : 'logout',
         handler : function() { }
     }, mainTabPanel])
  });
发布评论

评论列表(0)

  1. 暂无评论