PDA

View Full Version : Ext.MessageBox customize buttons name



wrongt
11 Nov 2011, 4:26 AM
Hi,
I can't change default ok and cancel buttons name in MesasgeBox, my code :


Ext.MessageBox.show({
title:'Change confirm',
msg: 'Please confirm changes?',
buttons: Ext.Msg.OKCANCEL,
buttonText: {ok: 'confirm', cancel: 'don't confirm'},
icon: Ext.MessageBox.QUESTION
});



when this code is running the name of buttons are the same as default('Ok', 'Cancel') not that what i defined in buttonText properties, i try all founded methods in sencha forum but no one help me to rename buttons.
It is a proper way in ext js 4.0.7 to change default buttons name in message box?
Thanks in advance.

tobiu
11 Nov 2011, 5:07 AM
take a look at the locale folder containing the localization files. there you have:



Ext.MessageBox.buttonText = {
ok : "OK",
cancel : "Cancel",
yes : "Yes",
no : "No"
};


you can change that (or override it later) to fullfil your needs.

wrongt
11 Nov 2011, 5:20 AM
I append to my code this lines


<link rel="stylesheet" type="text/css" href="/extjs/resources/css/ext-all-gray.css">
<script type="text/javascript" src="/extjs/ext-all.js"></script>
<script type="text/javascript" src="/extjs/locale/ext-lang-ro.js"></script>

now i must have Romanian locale for ExtJs , and if i want that MessageBox to show ok and the cancel button, buttons must have names form locale/ext-lang-ro.js

Ext.MessageBox.buttonText = {
ok : "OK",
cancel : "Renun??",
yes : "Da",
no : "Nu"
};
but with this code :

Ext.MessageBox.show({
title:'Change confirm',
msg: 'Please confirm changes?',
buttons: Ext.Msg.OKCANCEL,
icon: Ext.MessageBox.QUESTION
});
the text of buttons is 'Ok' and 'Cancel', but must be 'OK' and ' Renun??'. Can i solve this?

skirtle
11 Nov 2011, 5:23 AM
Last time I checked the locale files didn't work for message boxes. Try this:

http://www.sencha.com/forum/showthread.php?154185

wrongt
11 Nov 2011, 5:58 AM
trying this code:


var ok = Ext.MessageBox.down('#ok');
ok.setText('confirm');
var cancel = Ext.MessageBox.down('#cancel');
cancel.setText('don't confirm');
Ext.MessageBox.show({
title:'Change confirm',
msg: 'Please confirm changes?',
buttons: Ext.Msg.OKCANCEL,
icon: Ext.MessageBox.QUESTION
});

yes, it is override default buttons name.
Thanks for quick answers.

mitchellsimoens
11 Nov 2011, 6:32 PM
I should get the answer on this thread :D

MNMNT
8 Oct 2013, 5:36 AM
I should get the answer on this thread :D

What's the point of putting in documentation when it clearly doesn't work? It's set in Ext.MessageBox; buttonText in the 4.07 documentation but yet it doesn't work at all.