如何在sencha中设置Ext.Msg.show的位置 [英] How to set a position to Ext.Msg.show in sencha

查看:281
本文介绍了如何在sencha中设置Ext.Msg.show的位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在senchatouch中为Ext.Msg.show设置不同的位置。我尝试使用方法

How can I set a different position for Ext.Msg.show in senchatouch. I have tried using the methods

msg.getDialog().getPositionEl().setTop(50);

&

msg.getDialog().setPosition(undefined,50)

但是我收到错误 Object [object Object]没有方法'getPositionEl' Object [object Object]没有方法'getDialog'

我甚至在sencha的MessageBox.js文件中检查了这些方法但它们不存在。

I have even checked these methods in my MessageBox.js file in sencha but they do not exist.

然而,几乎在网上的解决方案似乎推荐这些方法。你可以建议你。

However almost solution on the net seems to recommend these methods.Experts could you kindly advise.

推荐答案

您可以通过指定 left top 配置选项将消息框放置到某个位置。 / p>

You can place messagebox to certain position by specifying left and top config options.

launch: function() {
    var msg = Ext.Msg.show({
            title:'Some title',
            message:'Sample message container.',
            left:50, // mention initial positioning with left and top config.
            top:50,
            buttons:[{  //create as many buttons you want. 
                text:'Ok',
                ui:'action',
                handler:function(btn){
                    if(msg.getTop() == 200) // Just for demo. Click Ok and place msg box to some other position. If clicked again, hide message box
                        msg.hide();
                    else{
                        msg.setTop(200); 
                        msg.setLeft(200);
                    }
                }
            }]
    });
}

除了配置选项,您可以将消息框与 setTop() setLeft()方法。

Other than config options, you can align message box with setTop() and setLeft() methods as well.

请参阅演示。如您所见,消息框不会放置在中央,因为它的默认位置是中心,而是放在顶部和左侧设置为50。

See Demo. As you can see, message box is not placed at center as it's default position is center but instead it is placed with top and left set to 50.

这篇关于如何在sencha中设置Ext.Msg.show的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆