zoukankan      html  css  js  c++  java
  • 动态添加一个控件到viewport中去

    代码
    Ext.namespace('IAMadmin');

    IAMadmin.MainApp 
    = function() {
               
        
    // public space
        return {
            
    // public properties
            viewport: false,
            container_west: 
    false,
            container_center: 
    false,
            
            
    // public methods
            init: function() {
                
                
    this.container_west = new Ext.Panel({
                    region: 
    'west',
                    id: 
    'container_west',
                    hideBorders: 
    true
                });
                
    this.container_center = new Ext.Panel({
                    region: 
    'center',
                    id: 
    'container_center',
                    hideBorders: 
    true
                });
                
                
    this.viewport = new Ext.Viewport({
                    layout: 
    'border',
                    items: [{
                        region: 
    'north',
                        xtype: 
    'mainmenu'                // I created this one
                    },
                    
    this.container_west,
                    
    this.container_center
                    ]
                });
            }, 
    // end of init
            
            onClick: 
    function(obj,evt) {
                
    var treePanelBuilder    = new Ext.ux.TreePanelBuilder();
                
    var treePanel            = treePanelBuilder.buildTreePanel();
                
                
    this.container_west.setWidth(200);
                
    this.container_west.add(treePanel);
                
                
    this.viewport.doLayout();
            }
        };
        
    }(); 
    // end of application

    基本的思路就是先生成一个容器,比如一个panel1,,在声明viewport的时候把这个容器加进去(items:panel1),然后把需要动态添加的控件添加到panel1

    panel1.add(一个控件);

    panel1.doLayout();

    注意:容器添加后,需要调用doLayout方法,以便更新容器界面

  • 相关阅读:
    转C++的一点点
    无向图hash
    字符串相关
    Tutte矩阵求一般图最大匹配
    FFT的常数优化
    洲阁筛
    半平面交
    非旋treap套线段树
    点分治 [IOI2011]Race
    treap
  • 原文地址:https://www.cnblogs.com/timy/p/1783931.html
Copyright © 2011-2022 走看看