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

decimals separator, inline editing

5 Answers 239 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jacob
Top achievements
Rank 1
Jacob asked on 01 Apr 2015, 09:19 AM
Hi,

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

Sort by
0
Rosen
Telerik team
answered on 03 Apr 2015, 07:48 AM
Hello Jacob,

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.

 
0
Jacob
Top achievements
Rank 1
answered on 15 Apr 2015, 01:11 PM

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.

0
Rosen
Telerik team
answered on 16 Apr 2015, 07:13 AM
Hello Jacob,

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.

 
0
Jacob
Top achievements
Rank 1
answered on 12 May 2015, 09:13 AM

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.

0
Accepted
Rosen
Telerik team
answered on 13 May 2015, 08:48 AM

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
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Jacob
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Jacob
Top achievements
Rank 1
Share this question
or