2015-10-16 52 views
1
GraphReportPanel = function (config, initData) { 
GraphReportPanel.instance = this; 


this.graphPanel = new Ext.Container({ 
    id : 'graphPanelId' 
}); 

GraphReportPanel.superclass.constructor.call(this, { 
    title : 'Graph', 
    autoScroll: true, 
    id : 'graphReportPanel', 
    items: [this.graphPanel], 
    collapsible : false 
}); 

}; 

我已經創建GraphReportPanel。現在,當我使用以下代碼無法獲取Ext.Component的el元素

Ext.getCmp('graphPanelId').el.dom.innerHTML = ''; 

我得到Ext.getCmp('graphPanelId').el未定義。爲什麼這樣?

回答

1

getEl()只返回如果組件呈現的DOM元素。在調用此方法之前,請檢查組件是否已呈現。

希望它有幫助。

+0

該組件未呈現。但是什麼時候渲染髮生在extjs中的一個組件。我是JavaScript新手,所以我不理解它。 – salsa111

+0

您已經將graphPanel容器作爲GraphReportPanel的一個項目。我不知道將哪個組件添加到GraphReportPanel,以及其他組件或文檔主體。 'renderTo:Ext.get('my-div-name')'或'renderTo:Ext.getBody()'將完成這項工作。 – Gilsha