PDA

View Full Version : [CLOSED] Numberfiel in Brazilian currency



ucaneto
Apr 30, 2015, 7:50 PM
how can I do when entering a value in a Numberfiel it matches the format in Brazilian currency?


example: R$ 77.600,00

Tks.

Ulisses

Daniil
May 01, 2015, 1:22 PM
Hi @ucaneto,

Unfortunately, NumberField doesn't support formatting.

You could try with a TextField if appropriate. The best solution we could suggest is to format on blur and remove formatting on focus.

Example

<%@ Page Language="C#" %>

<!DOCTYPE html>

<html>
<head runat="server">
<title>Ext.NET v2 Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server">
<Listeners>
<DocumentReady Handler="Ext.util.Format.currencySign = 'R$';" />
</Listeners>
</ext:ResourceManager>

<ext:TextField runat="server" MaskRe="[0-9\.]">
<Listeners>
<Focus Handler="this.setValue(this.getValue().replace(/[R$\,]/g, ''));" />
<Blur Handler="this.setRawValue(Ext.util.Format.currency(this.get RawValue()));" />
</Listeners>
</ext:TextField>
</form>
</body>
</html>

ucaneto
May 01, 2015, 3:23 PM
Thank Daniil, so one more doubt has as I change the point comma?
in Brazil the currency is so R $ 77,106.25 and R $ 77,106.25 not.


The Ext.net support is the best of all.

Daniil
May 04, 2015, 9:17 PM
Thank you for the find words!

There are the thousandSeparator and decimalSeparator settings.
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.util.Format-property-decimalSeparator
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.util.Format-property-thousandSeparator

Example

<%@ Page Language="C#" %>

<!DOCTYPE html>

<html>
<head runat="server">
<title>Ext.NET v2 Example</title>

<script>
var onDocumentReady = function () {
Ext.apply(Ext.util.Format, {
thousandSeparator: ".",
decimalSeparator: ",",
currencySign: "R$"
});
};
</script>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server">
<Listeners>
<DocumentReady Fn="onDocumentReady" />
</Listeners>
</ext:ResourceManager>

<ext:TextField runat="server" MaskRe="[0-9,]">
<Listeners>
<Focus Handler="this.setValue(this.getValue().replace(/[R$\.]/g, ''));" />
<Blur Handler="this.setRawValue(Ext.util.Format.currency(this.get RawValue().replace(',', '.')));" />
</Listeners>
</ext:TextField>
</form>
</body>
</html>