This is a migrated thread and some comments may be shown as answers.
Inline Editing with Float Values
1 Answer 2 Views
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 18 Dec 2020, 01:15 AM

So this is a bit of a strange one.  Have a database where items are stored in float due to the variance of the decimal points.  So you will commonly find scientific notation (7e-8 for example).  I am using Inline Editing on the grid and have use this to display the number as a decimal:

{
                field: "testValue",
                title: "Value",
                width: 100,
                editor: customNumberEditor,
                template: "#= kendo.toString(testValue, 'n' + schemeNomRes)#"
}

 

However, when you click the Edit Button in the row.  The text field reverts back to Scientific Notation.  My function for customNumberEditor is pretty basic:

function customNumberEditor(container, options) {
    $("<input required name=\"" + options.field + "\" onkeypress= \"return isNumber(event)\">").appendTo(container);
}

Is there something I could do there to ensure that the number appears in my textbox as: 0.00000008 in this example?

Thanks,

Richard

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 21 Dec 2020, 05:05 PM

Hi Richard,

The described behavior is expected, and it is caused by the Number object. Since internally the numbers in JS are represented via Doble-precision floating-point (IEEE-754 64-bit) you would be unable to represent some numbers without the scientific notation.

As this is an issue that is caused by the JS itself, currently the only workaround I can suggest is to use strings instead of numbers to avoid the scientific notation.

Let me know if you ahve any questions.

Regards,
Nikolay
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
Richard
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Share this question
or