PDA

View Full Version : [CLOSED] DecimalSeparator in NumberField



UnifyEducation
Jul 22, 2013, 10:29 AM
Hi,

I'm developing a multi-language site. When I work with NumberField in French, the decimal separator is ",". And I must type "," in the keyboard for the decimal number. But in the keyboard, there is a number pad on the right with "." character. In many other application like microsoft excel, it converts automatically "." to "," when I press this button.
So, my question is: How can I use "," and "." (on the number pad) buttons for decimal separator. And on the screen, it shows only ","?

Thank you,


@model dynamic

@{ Layout = null;}

@Html.X().ResourceManager().Locale("fr")

@(Html.X().FormPanel().Title("Test NumberField")
.Items(i =>
{
i.Add(Html.X().NumberField().FieldLabel("Test NumberField"));
}))

Daniil
Jul 22, 2013, 3:27 PM
Hi @UnifyEducation,

I would try to override a NumberField's filterKeys function.

Example

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

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

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

<script>
var myfilterKeys = Ext.Function.createSequence(Ext.form.field.Number. prototype.filterKeys, function (e) {
var charCode = String.fromCharCode(e.getCharCode());

if (charCode === "." && this.decimalSeparator === ",") {
this.setRawValue(this.getRawValue() + ",");
}
});
</script>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" Locale="fr" />

<ext:NumberField runat="server">
<CustomConfig>
<ext:ConfigItem Name="filterKeys" Value="myfilterKeys" Mode="Raw" />
</CustomConfig>
</ext:NumberField>
</form>
</body>
</html>