javascript ExtJs 4 - Window.show() - 窗口大小非常小

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6050845/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 19:17:17  来源:igfitidea点击:

ExtJs 4 - Window.show() - window size is very small

javascriptextjs

提问by sambomartin

I'm getting to grips with ExtJs 4 and having an issue showing a modal window upon a double click event on a grid.

我开始掌握 ExtJs 4 并遇到在网格上双击事件时显示模态窗口的问题。

A listener defined on grid component:

在网格组件上定义的侦听器:

"listeners": {
    "itemdblclick": function() { 
        var win =Ext.getCmp('myCmp');
        win.myWindow.show(); 
    }
}

previously defined property of myCmp to be a window component: (I've used the parent container object myCmp as I'm code generating the javascript to build the ExtJs config)

之前定义的 myCmp 属性是一个窗口组件:(我使用了父容器对象 myCmp 作为我的代码生成 javascript 来构建 ExtJs 配置)

myCmp.myWindow = Ext.create('Ext.window.Window',{
"layout": "fit",
"items": [
 ....     
],
"title": "Hello Window",
"width": "300",
"height": "300",
"id": "myWindow"
});

The logic works well, I double click the grid, the window object is present (myCmp.myWindow) but when i call show() the window is displayed very small (6px x 6px).

逻辑运行良好,我双击网格,窗口对象存在 (myCmp.myWindow) 但当我调用 show() 时,窗口显示得非常小(6px x 6px)。

if I change the handler to :

如果我将处理程序更改为:

Ext.create('Ext.window.Window',{
"layout": "fit",
"items": [
 ....     
],
"title": "Hello Window",
"width": "300",
"height": "300",
"id": "myWindow"
}).show();

It works ok. obviously this is creating a new window instance.

它工作正常。显然这是创建一个新的窗口实例。

Any ideas? am I doing this right?

有任何想法吗?我这样做对吗?

Thanks in advance

提前致谢

sam

山姆

回答by Abdel Raoof

Why do you refer to "myCmp" when you can directly refer to your window?

当您可以直接引用您的窗口时,为什么要引用“myCmp”?

 var win = Ext.getCmp('myWindow');
 win.show();

This should work. Also, Why do you instantiate a window else where and then use it? Wouldn't it be better to create a instance when you need it and destroy it after use?

这应该有效。另外,为什么要在其他地方实例化一个窗口然后使用它?需要的时候创建一个实例,用完就销毁不是更好吗?

Also, you should configure the window correctly. The width and height are numeric fields and not string. Refer to api documentation and examples to see how to configure the objects properly. you should use the following window:

此外,您应该正确配置窗口。宽度和高度是数字字段而不是字符串。请参阅 api 文档和示例以了解如何正确配置对象。您应该使用以下窗口:

Ext.create('Ext.window.Window',{
    layout: 'fit',
    items: [
     ....     
    ],
    title: 'Hello Window',
    width: 300,
    height: 300,
    id: 'myWindow'
}).show();