Decimal format problem about relation between comma and dot into NumericTextBox

9 posts, 0 answers
  1. Nihat
    Nihat avatar
    3 posts
    Member since:
    Dec 2012

    Posted 24 Jun 2013 Link to this post

    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
  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 25 Jun 2013 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
  4. Marco
    Marco avatar
    23 posts
    Member since:
    Jan 2014

    Posted 27 Mar 2014 Link to this post

    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
  5. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 28 Mar 2014 Link to this post

    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!
     
  6. Marco
    Marco avatar
    23 posts
    Member since:
    Jan 2014

    Posted 28 Mar 2014 in reply to Georgi Krustev Link to this post

    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?
  7. Marco
    Marco avatar
    23 posts
    Member since:
    Jan 2014

    Posted 31 Mar 2014 Link to this post

    Why is the grid displaying the same value correct? This should also display 808?
  8. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 31 Mar 2014 Link to this post

    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!
     
  9. Marco
    Marco avatar
    23 posts
    Member since:
    Jan 2014

    Posted 01 Apr 2014 Link to this post

    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 }
                                          ],
                                  });
  10. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 02 Apr 2014 Link to this post

    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!
     
Back to Top
Kendo UI is VS 2017 Ready