I have a problem with decimal separators when doing inline editing.
Right now I have a solution that works, but I need more than two digits after the decimal separator:
The model:
[DataType("number")]
public double Percent
{
get { return (double)Math.Round(source.Percent, 5); }
set { source.Percent = (decimal)value; }
}
The view:
.Columns(columns =>
{
columns.Bound(c => c.Percent).Title(Resource.Percent).Format("{0:n5}");
Setting the culture:
var c = '@System.Globalization.CultureInfo.CurrentCulture.ToString()'
kendo.culture(c);
The DataType=number, in the model, formats the inline input box the correct way.
The "Format("{0:n5}")", in the view, formats the number correctly in the grid.
There is no problems when updating the model (model-state is valid), but I need higher precision.
thanks.
5 Answers, 1 is accepted
I'm afraid I'm not sure what is the exact issue you are facing. Is it that the NumericTextBox widget does not show the decimals during editing? If this is the case you may need to change the editor widget configuration, for example:
@(Html.Kendo().NumericTextBoxFor(m => m)
.HtmlAttributes(
new
{ style =
"width:100%"
})
.Decimals(5)
)
Regards,
Rosen
Telerik
See What's Next in App Development. Register for TelerikNEXT.

Hi Rosen,
No, the width is fine.The problem is that it won't show more than two digits after the decimal separator.
The solution I'm talking about (the question) does only show two digits, i need five.
Thanks.
The suggestion I was trying to make is to use the Decimals method of the widget to increment the decimals. Did this not work?
Regards,
Rosen
Telerik
See What's Next in App Development. Register for TelerikNEXT.

Hi Rosen,
I don't know what it is I should test - Decimals() is not a valid method to Columns ??
I believe you miss the point here (or I'm not able to explain it):
* If I don't add the DataType attribute to the model ([DataType("number")]), the decimal separator is not following the culture settings on editing (the decimal separator is following the English culture only, but only on inline edit).
* If I use the DataType attribute, I can't select a type, that gives me more than two decimals.
Thanks.
Hello Jacob,
The Decimals is setting of the NumericTextBox widget which is used as an EditorTemplate. This is where the change should be made.
Regarding the DataType attributes - as you know this attribute purpose is to instruct the ASP.NET MVC framework which EditorTemplate should be instantiated for the decorated property when set in edit mode. Thus, setting the DataType to number usually will instantiate the EditorTemplate named Number.cshtml. This is where you will need to apply the required changes to the editor widget.
Information on using EditorTemplate in the context of our Grid widget can be found here. For general information on Editor Templates see Brad Wilson's blog series on ASP.NET MVC 2 Templates.
If you continue to experience difficulties please provide a small runnable sample which demonstrates the issue.
Regards,Rosen
Telerik