How to set a position to Ext.Msg.show in sencha

半腔热情 提交于 2019-12-11 11:42:14

问题


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)

However I am getting a error Object [object Object] has no method 'getPositionEl' or Object [object Object] has no method 'getDialog'.

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.


回答1:


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);
                    }
                }
            }]
    });
}

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

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.



来源:https://stackoverflow.com/questions/15879410/how-to-set-a-position-to-ext-msg-show-in-sencha

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!