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
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

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
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

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
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

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
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.

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
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.

how can I provide you a sample project. 2 MB are just to small.
Greets
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.

you can download the project here: https://www.dropbox.com/l/Hyd6uXqgmbjptykvyG1MRu
Thanks and Regards
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.

thank you very much.
Greets
Sascha

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

Please ignore the last post.. Works as expected.
Thanks
Holger