This is a migrated thread and some comments may be shown as answers.

Decimal format problem about relation between comma and dot into NumericTextBox

8 Answers 2480 Views
NumericTextBox
This is a migrated thread and some comments may be shown as answers.
Nihat
Top achievements
Rank 1
Nihat asked on 24 Jun 2013, 06:51 AM
I have tried to use Turkish format for NumericTextBox, and also I want to convert dot sign of decimal to comma. However, position of sign comma have gone to wrong position on the decimal number (For Example: when I change format to convert dot to comma, then 1.5 number to be 15,00)
How Can I figure out the problem?
Thanks a lot,
Nihat Erdil

8 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 25 Jun 2013, 02:17 PM
Hello Nihat,

 
This is a known issue, which is already addressed. The fix is included in the last internal build of Kendo UI, which is available only for paid customers.

Regards,
Georgi Krustev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Marco
Top achievements
Rank 1
Iron
answered on 27 Mar 2014, 10:41 AM
This issue still exists today. The value "80.8" is displayed as 808,00.

culture: "nl-NL",
format: "n1"

I have a kendo grid with a formatted decimal column: format: "{0: n1}", works like a charm!

Any ideas somebody?

Kind Regards,

Marco
0
Georgi Krustev
Telerik team
answered on 28 Mar 2014, 03:03 PM
Hello Marco,

According the nl-NL cultures script, the decimal separator "," (comma) and the thousands separator is "." (dot). Hence when a value like "80.8" is set, the widget will recognize it as "808". Here is a simple example showing what the difference is. To avoid this expected behavior, set the widget's value with correctly formatted value "80,8".

Regards,
Georgi Krustev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Marco
Top achievements
Rank 1
Iron
answered on 28 Mar 2014, 03:42 PM
So it's not possible to work with invariant values i retrieve from a web service? How would i do this when a user uses our application with a different culture? I have to reformat every value i retrieve based on the culture of the current user?
0
Marco
Top achievements
Rank 1
Iron
answered on 31 Mar 2014, 08:53 AM
Why is the grid displaying the same value correct? This should also display 808?
0
Georgi Krustev
Telerik team
answered on 31 Mar 2014, 12:42 PM
Hello again Marco,

The NumericTextBox widget parses the numeric string set from the server using the current Kendo culture. That is why when the culture is set to "nl-NL" values with incorrect decimal separator will be parsed incorrectly (discussed in my previous reply). The widget posts values to the server using a decimal separator defined in the current culture. In other words if the current decimal separator is "," (comma), widget will post the value with same decimal separator, for instance, "80,8". If you want to support different cultures then you will need to know what is the browser culture and based on this information to parse the input values. Other option is to use "en-US" culture to simulate invariant culture.

The Grid widget can be configured to use an Ajax for CRUD operations. In this case, it will send JSON to the server, where the model's field which is number will be sent as such. Here is a jsBin demo depicting my statement.

You can post form values manually using Ajax. Thus you can gather the values of the inputs/widgets and send them formatted in the way you need to.

Regards,
Georgi Krustev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Marco
Top achievements
Rank 1
Iron
answered on 01 Apr 2014, 12:31 PM
Hi Georgi,

I configured my Grid as displayed below.
As you can see, I'm getting JSON formatted data from the server. The Kg column is the same
data as I used with the NumericTextBox. The only difference is that the format n1 works correctly in
the grid column (while being displayed, I do not update data from the Grid),
and it's displayed incorrect (perception) by the NumericTextBox.

Can it be that the Grid internally calls a Number.toLocaleString()? Anyway, I
used the Number.toLocaleString method prior to the assignment of the value to
the NumericTextBox, which works fine. I really appreciate the effort you’ve put
in this question. Thanks!



​
$("#grid").kendoGrid({
                  dataSource: {
                      transport: {
                          read: {
                              type: "POST",
                              contentType: "application/json; charset=utf-8",
                              url: getBaseUrl() + "/Service.asmx/JSONData",
                              data: function (e) {
                                  return {
                                      "a": A(),
                                      "b": _B()
                                  }
                              }
                          },
                          parameterMap: function (options) {
                              return kendo.stringify(options);
                          }
                      },
                      schema: {
                          data: "Data",
                          total: "Total",
                          model: {
                              id: "Id",
                              fields: {
                                  Datum: { field: "Datum", type: "date" }
                              }
                          },
                          parse: function (response) {
                              return JSON.parse(response.d);
                          }
                      },
                      pageSize: 10,
                  },
                  height: 450,
                  width: 800,
                  filterable: false,
                  sortable: false,
                  pageable: gridPagerLocalizationObject["pageable"],
                  selectable: "cell",
                  columns: [
                          { title: "C", field: "C", width: 50 },
                          { title: "Datum", field: "Datum", format: "{0:d}", width: 70 },
                          { title: "V", field: "V", width: 50 },
                          { title: "Kg", field: "Kg", format: "{0:n1}", width: 50 },
                          { title: "RR B", field: "RRB", width: 50 },
                          { title: "RR O", field: "RRO", width: 50 },
                          { title: "A", field: "A", width: 50 },
                          { title: "O", field: "O", width: 50 }
                                      ],
                              });
0
Georgi Krustev
Telerik team
answered on 02 Apr 2014, 02:15 PM
Hello Marco,

The Grid widget works with JSON and formats Number objects to specified format using current culture. That is why it displays the value formatted correctly. It just works with Number objects. The NumericTextBox on the other hand can be initialized either with string numeric value or with Number object. If the first option is used, then the string numeric value should use the current culture decimal separator. If you set the value through the value option as a Number object, then the widget will work as expected too. Check this Kendo Dojo demo, which examines the possible scenarios.

Regards,
Georgi Krustev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
NumericTextBox
Asked by
Nihat
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Marco
Top achievements
Rank 1
Iron
Share this question
or