If you use the code with the default buttons:
Ext.Msg.show({
title:'Save Changes?',
msg: 'You are closing a tab that has unsaved changes. Would you like to save your changes?',
buttons: Ext.Msg.YESNOCANCEL,
icon: Ext.Msg.QUESTION
});
the buttons on the window are in the order yes - no - cancel. I would like them in the order cancel - no - yes for consistency in my app. Is there a way to add a different configuration or change this for my needs?
Default buttons is simply created within Ext.window.MessageBox.makeButton() private method based on Ext.window.MessageBox.buttonIds config and show / hide based on bitmask buttons: Ext.Msg.YESNOCANCEL
.
So we just have to override buttonIds
config and bitmasks:
Ext.define('Ext.overrides.MessageBox', {
override: 'Ext.window.MessageBox',
OK: 1, //0001
CANCEL: 2, //0010
NO: 4, //0100
YES: 8, //1000
OKCANCEL: 3, //0011
YESNO: 12, //1100
YESNOCANCEL: 14, //1110
buttonIds: [
'ok', 'cancel', 'no', 'yes'
]
});
Ext.Msg
/ Ext.MessageBox
is singletones and initially defined as instance of Ext.window.MessageBox
before our override (check last lines of Ext.MessageBox code).
So we have to override Ext.Msg
/ Ext.MessageBox
aswell:
Ext.Msg = Ext.MessageBox = new Ext.window.MessageBox();
Check this simple fiddle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With