Rohan More
Rohan More

Reputation: 131

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

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.

Upvotes: 1

Views: 3736

Answers (1)

SachinGutte
SachinGutte

Reputation: 7055

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.

Upvotes: 1

Related Questions