goodfifa06 2009-11-09 11:18
浏览 375
已采纳

Ext Toolbar 动态添加按钮

[code="java"]
var toolBar = new Ext.Toolbar({});
var bb = {
text : 'TEXT',
id : 'bb_id'
}
var button = new Ext.Button({
text : 'ADD',
renderTo : 'button_id',
handler : function(){
//add button for toolbar
toolBar.items.add('bb_id',bb); //This is not work
}
})
[/code]

  • 写回答

1条回答 默认 最新

  • zhoujuan520 2009-11-10 08:22
    关注

    Notes :

    * If the Container is already rendered when add is called, you may need to call doLayout to refresh the view which causes any unrendered child Components to be rendered. This is required so that you can add multiple child components if needed while only refreshing the layout once. For example:
    
      var tb = new Ext.Toolbar();
      tb.render(document.body);  // toolbar is rendered
      tb.add({text:'Button 1'}); // add multiple items (defaultType for Toolbar is 'button')
      tb.add({text:'Button 2'});
      tb.doLayout();             // refresh the layout
    

    意思就是动态添加后,需要调用toolbar的doLayout()刷新一下布局

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘