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

Decimal separator ignored with de-De culture.

16 Answers 1695 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Malcolm
Top achievements
Rank 1
Malcolm asked on 19 Jun 2013, 01:02 PM
Dear Telerik Team!
I've got an essential problem updating a decimal value in a grid.

The model property is annotated wird a weight datatype attribute


        [DataType("Weight")]
        public decimal WeightGross { get; set; }

And the Editortemplate for weight is this:

"
model decimal

@(Html.Kendo().NumericTextBoxFor(m => m)
      .Spinners(false)
)
"

The Problem ist the following: When the culture ist set to "de-DE" the value cannot be correctly updated. The decimal separator is ignored!
If I edit the grid row and enter e.g. '3,25' following happens:
- If I press Tab to go to the next colum the value is correctly shown as '3,25'
- But If I click Update, the value submitted to the controller is 325!

I think this has s.th. to do with the fact that the decimal separator is ',' and not '.' with "de" culture.
If I change the culture to "en" and use '.' as decimal separator it works.
Am I missing s.th or is this a bug in the framework?

brgds
Malcolm Howlett

p.s. If I omit the Datatype annotation it does not get better:
 - I can use ',' as the decimal separator in edit mode
 - but after moving to the next column the value is displayed with '.' decimal separator
- When submittin the decimal separator is still ignored. 3,25 (3.25) becomes 325.

16 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 21 Jun 2013, 12:05 PM
Hello Malcolm Howlett,

This is a known issue in the service pack release that is already fixed. Please try with the latest internal build and let me know if you still experience this problem.

Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Malcolm
Top achievements
Rank 1
answered on 22 Jul 2013, 01:31 PM
Hello Daniel!
I updated to version 2013.2.716 today, assuming the problem will be solved.
I was wrong. It is still not possible to enter floating point numbers in 'de-de' culture.
What can I do to handle this issue?
Please help!
We would like to start using KendoUI in productive environment soon.

brgds
Malcolm Howlett
0
Daniel
Telerik team
answered on 24 Jul 2013, 12:14 PM
Hello Malcolm,

I tried to reproduce the problem with the new version but to no avail. I attached my test project. Please check it and let me know if the numerictextbox works as expected on your side.

Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Malcolm
Top achievements
Rank 1
answered on 24 Jul 2013, 04:47 PM
Hello Daniel!
Your test project works fine if you add a html.beginform and a submit button. There You can use the numerictextbox.
But the problem ist that it does not work inside a grid. Attached You find a project that shows the problem. Please add breakpoints to the [HTTPPost] Methods in the controller.
In the about page, you can use the numerictextbox as expected.
But in the grid on the index page, you will get an invalid ModelState in the controller method if you try to change the weight to e.g. '1,6'.
If you inspect the raw values in the ModelStat you will find out that in the first case, '1,6' is provided as raw value, but in the 'grid' case, '1.6' is provided as raw value in the contoller.
Looks like the value is changed somehow.
I still have no idea why the raw value '1.6' leads to an invalid model state in the provided test project, and in my project it is converted to 16 and the model state is valid.

You will have to add Kendo Scripts to the provided project manually. They made the project to large, so I had to remove them.

brgds
Malcolm Howlett
0
Accepted
Daniel
Telerik team
answered on 26 Jul 2013, 09:23 AM
Hello again,

Thank you for sending a sample project and sorry for missing that this problem will occur. The dataSource will sent the numbers with dot as decimal separator and so the numbers will not be parsed correctly. At least for now, this should be handled either with a custom model binder as demonstrated here or in the request Data function. I attached the project modified to show the second option.

Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Sascha
Top achievements
Rank 1
answered on 20 Dec 2014, 02:00 PM
Hello,

I run in the same problem. I have createt a new project via wizard and added a data access domain model. I have follwed the instructions from http://docs.telerik.com/kendo-ui/aspnet-mvc/globalization. But I still get "." as decimal seperator.

To dig deeper, I have downloaded the sample project for VS2013 today and I get the same error after changing the datatype of the unitprice fom DataType.Currency to decimal (...\Kendo.Mvc.Examples\Models\ProductViewModel.cs):

[DisplayName("Unit price")]
//[DataType(DataType.Currency)]
[DataType("decimal")]
[Range(0, int.MaxValue)]
public decimal UnitPrice
{
    get;
    set;
}

Inline and PopUp editing are affected.

If I change the DataType in my solution to DateType.Currency a "," i schowen as decimal seperator.

IHow can I solve this problem?

Thanks and regards
Sascha
0
Vladimir Iliev
Telerik team
answered on 23 Dec 2014, 12:56 PM
Hi Sascha,


From the provided information it seems that you are using regular input as editor instead of the NumericTextBox - could you please try to use the following editor and let us know of the result:

@model decimal?
 
@(Html.Kendo().NumericTextBoxFor(m => m)     
      .Decimals(2)
      .HtmlAttributes(new {style="width:100%"})
      .Min(0)
)

For more information about how to set custom editor templates for the model fields you can check the following help article:

Regards,
Vladimir Iliev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Sascha
Top achievements
Rank 1
answered on 10 Jan 2015, 10:00 AM
Hello Vladimir,

thank you very much for your reply.

An editor (Number.cshtml) was generated by the new profect wizard. I just changed the datatype from double? to decimal?.

As descripted in the help article, adding UIHint and DataAnnotations did the trick:

[DisplayName("Unit price")]
//[DataType(DataType.Currency)]
[DataType("decimal")]
[Range(0, int.MaxValue)]
[System.ComponentModel.DataAnnotations.DisplayFormat(DataFormatString = "{0:#,##0.00}", ApplyFormatInEditMode = true)]
[UIHint("Number")]
public decimal UnitPrice
{
    get;
    set;
}

A belated happy new year
Sascha
0
Vladimir Iliev
Telerik team
answered on 12 Jan 2015, 08:26 AM
Hi Sascha,

I tried to reproduce the problem locally but to no avail – everything is working as expected on our side. Could you please provide runable project where the issue is reproduced? This would help us pinpoint the exact reason for this behavior.

Regards,
Vladimir Iliev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Sascha
Top achievements
Rank 1
answered on 16 Jan 2015, 03:29 PM
Hello Vladimir,

how can I provide you a sample project. 2 MB are just to small.

Greets
Sascha
0
Vladimir Iliev
Telerik team
answered on 19 Jan 2015, 10:03 AM
Hi Sascha,

You can for example open a new support ticket (include link to current thread in the ticket) where the upload limit is 20mb or upload the archive in one of the free cloud services and provide the link here.

Regards,
Vladimir Iliev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Sascha
Top achievements
Rank 1
answered on 07 Feb 2015, 10:19 AM
Hi Vladimir,

you can download the project here: https://www.dropbox.com/l/Hyd6uXqgmbjptykvyG1MRu

Thanks and Regards
Sascha
0
Vladimir Iliev
Telerik team
answered on 11 Feb 2015, 08:55 AM
Hi Sascha,

Thank you for the provided project.

After setting the project culture to "de-DE" in the WebConfig file the decimal separator start working as expected in the editor inside the Grid:

Class:
private decimal _price;
[Required()]
[UIHint("Decimal")]
public virtual decimal Price

Grid configuration:
columns.Bound(product => product.Price).Format("{0:n}");

WebConfig:
<system.web>
    <globalization culture="de-DE" uiCulture="de-DE"/>

Regards,
Vladimir Iliev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Sascha
Top achievements
Rank 1
answered on 21 Feb 2015, 09:18 AM
Hi Vladimir,

thank you very much.

Greets
Sascha
0
Holger
Top achievements
Rank 1
answered on 29 Jun 2015, 01:30 PM

Hello,

because this thread describes my current issue I will just reply here..I am currently running in the same issue using the latest version 2015.2 version of kendo mvc.

I am using de-DE culture (set in web config and set programatically). The call kendo.culture("de-DE") is executed without no errors as the console in browser shows.

The grid still shows decimal values in the wrong format. So the question: Is this issue back or did I miss something? 

Best regards,

Holger

 

0
Holger
Top achievements
Rank 1
answered on 29 Jun 2015, 01:48 PM

Please ignore the last post.. Works as expected. 

Thanks 

Holger

Tags
Grid
Asked by
Malcolm
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Malcolm
Top achievements
Rank 1
Sascha
Top achievements
Rank 1
Vladimir Iliev
Telerik team
Holger
Top achievements
Rank 1
Share this question
or