Ext中TablePanle只能获取ActiveTab的对象

项目需要,将一个对象的各个部分分到各个Tab中显示。但是通过Ext.getCom获取Id的方式只能获得到tabpanle中的激活对象。

var reviewSqlTabPanel = new Ext.TabPanel({
    activeTab:0,
    items:[
        {id:'sqlQuery',title:'XXX', html:''},
        {id:'sqlXml',title:'XXX', html:''},
        {id:'sqlExplain',title:'XXX', html:''}
    ]
});

Ext.getCmp('sqlXml').body.update('注释:'+sqlComment+"<br>"+"XML:"+sqlXml);
Ext.getCmp('sqlQuery').body.update(sqlQuery);

即获取sqlXml的时候报错,原来tabpanle只有在active的时候才会创建对应的dom对象,解决方案很简单

var reviewSqlTabPanel = new Ext.TabPanel({
    activeTab:0,
    deferredRender:false,
    items:[
        {id:'sqlQuery',title:'XXX', html:''},
        {id:'sqlXml',title:'XXX', html:''},
        {id:'sqlExplain',title:'XXX', html:''}
    ]
});

参考:http://www.iteye.com/problems/56865

Internally, the TabPanel uses a Ext.layout.CardLayout to manage its tabs. This property will be passed on to the layout as its Ext.layout.CardLayout.deferredRender config value, determining whether or not each tab is rendered only when first accessed (defaults to true in ExtJs)(defaults to false in this control).

总结一下,activeTab的其他tab如果需要提前渲染的时候需要加上deferrereRender为false这个选项。

你可能感兴趣的:(Ext中TablePanle只能获取ActiveTab的对象)