【问题标题】:Extjs - Cannot hide windowExtjs - 无法隐藏窗口
【发布时间】:2013-11-25 05:57:35
【问题描述】:

我正在使用 Extjs 4.2,但遇到了问题。

我创建了一个扩展“Window”的对象“Window_Graph”。当我试图隐藏这个对象时,它会产生一个 javascript 错误:“Uncaught TypeError: Cannot call method 'apply' of undefined”。

这是我的对象:

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();

谢谢。

【问题讨论】:

  • 您能否显示您想要隐藏的实例的代码?
  • 我已经编辑了我的帖子...谢谢。
  • 那里一定有其他问题导致问题,我在此页面的下一条评论中尝试了代码并且没有任何问题:try.sencha.com/extjs/4.2.0/docs/Ext.window.Window.1/viewer.html 你看到我拥有的与你拥有的不同吗有吗?
  • 我试过的代码:Ext.onReady(function () { 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',text: 'Modifier'}], autoShow: true, constrain: true }); Ext.create('Ext.panel.Panel', { id: 'myPanel', title: 'Test Panel', renderTo: Ext.getBody() }); Ext.getCmp('myPanel').add({xtype: 'window_graph', id:'myWin'}); Ext.getCmp('myWin').hide() });
  • 我也没有发现任何问题:jsfiddle.net/n3g4U/1

标签: extjs


【解决方案1】:

Ext.getCmp 在您的情况下正在返回 undefined ! 这就是错误消息告诉您的内容。

我想我知道你得到这个的原因。 初始化过程尚未完成。你打电话给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();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-04-13
    • 2020-11-28
    • 2019-06-23
    • 1970-01-01
    • 2013-02-23
    • 2018-08-13
    • 2020-07-10
    • 1970-01-01
    相关资源
    最近更新 更多