我正在使用Extjs 4.2,但我遇到了问题。
我创建了一个对象“Window_Graph”,它扩展了“Window”。当我尝试隐藏此对象时,会出现javascript错误:“未捕获的TypeError:无法调用方法'应用'未定义”。
有我的目标:
Ext.define('PFS.view.Window_Graph', {
extend: 'Ext.Window',
alias: 'widget.window_graph',
layout: 'fit',
border: false,
closable: true,
header: true,
draggable: true,
resizable: true,
border: false,
tbar: [
{ xtype: 'button', action: 'modifier', text: 'Modifier', iconCls: 'iconAppEdit' },
{ xtype: 'button', action: 'deplacer', text: 'Déplacer', iconCls: 'iconArrowOut' },
{ xtype: 'button', action: 'redimensionner', text: 'Redimensionner', iconCls: 'iconShapeHandles'},
{ xtype: 'button', action: 'supprimer', text: 'Supprimer', iconCls: 'iconCross' },
],
autoShow: true,
constrain: true
});
当我创建window_graph时:
Ext.getCmp('page1').add({
xtype: 'window_graph',
id: 'graph_1',
width: 500,
height: 300,
x: 10,
y: 10
});
接下来,我试着隐藏它:
Ext.getCmp('graph_1').hide();
感谢。
答案 0 :(得分:1)
Ext.getCmp 在您的案例中退出未定义! 这是错误消息告诉您的内容。
我想我知道你为什么会这样做。
初始化过程尚未完成。您过早地致电Ext.getCmp("graph_1")
。如果要在创建时隐藏窗口,请使用autoShow=false
。
或者您也可以尝试这个
var graphWindow = Ext.ComponentQuery.query("window_graph")[0];
debugger; //look in the console if you are getting an object back.
graphWindow.hide();