Hi, how can i remove any kind of automatic formatting from 'ejs-numerictextbox' control? It must show what is entered. The number of decimals can vary, it is not fixed.
Best regards,
Massimo
Hi Massimo,
We suggest setting the format property as per your requirement to avoid the auto round of the value entered by the user in the Numeric TextBox component. Please refer to the below documentation for more details.
|
<ejs-numerictextbox id="numeric" value="10" format="n5" ></ejs-numerictextbox> |
Documentation : https://ej2.syncfusion.com/aspnetcore/documentation/numerictextbox/formats
Supported Format String : https://ej2.syncfusion.com/aspnetcore/documentation/common/internationalization#supported-format-string
Sample : https://www.syncfusion.com/downloads/support/directtrac/general/ze/CoreNTB-614898080
Kindly try the above suggestion and let us know if this meets your requirement. If we misunderstood the requirement, we request you to provide additional details about the requirement as mentioned below. This will help us validate the requirement further and provide you with a better solution.
If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.
Udhaya Kumar D
Thank you for your response.
My problem is that the value should not be formatted at all, putting "n5" even the value 0.5 is displayed at 0.50000.
The same field can have values with different decimals, but this should not be formatted:
1.2 => 1.2
0.45 => 0.45
100 => 100
0.362 => 0.362
without additional decimals.
Regards,
Massimo
Hi Massimo,
We are validating the requirement. We will update the further details in two business days (3rd October 2022).
Udhaya Kumar D
Hi Massimo,
Sorry for the inconvenience.
We suggest setting the format property as “n” for your requirement. While setting the format property as n, the Numeric TextBox will accept the user input as it is and it will not format the input value.
If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.
Udhaya Kumar D
Sorry, but it still doesn't work, if I enter the value 0.00069 it is displayed as 0.001, instead of 0.00069:
<ejs-numerictextbox id="numericTextBoxTest" format="n">
</ejs-numerictextbox>
Regards,
Massimo
Hi Massimo,
We are validating the requirement. We will update the further details in two business days (6th October 2022).
Udhaya Kumar D
Hi Massimo,
We can achieve the requested requirement by overriding the source code. W have prepared a sample and shared it below for reference.
@{ ViewData["Title"] = "Home Page"; }
<ejs-numerictextbox id="numeric"format="n"></ejs-numerictextbox>
<script> ej.inputs.NumericTextBox.prototype.modifyText = function () { if (this.value || this.value === 0) { var value = this.formatNumber(); var elementValue = value; this.setElementValue(elementValue); Object(_ej2_base__WEBPACK_IMPORTED_MODULE_0__["attributes"])(this.element, { 'aria-valuenow': value }); this.hiddenInput.value = this.value.toString(); if (this.value !== null && this.serverDecimalSeparator) { this.hiddenInput.value = this.hiddenInput.value.replace('.', this.serverDecimalSeparator); } } else { this.setElementValue(''); this.element.removeAttribute('aria-valuenow'); this.hiddenInput.value = null; } } </script> |
Sample : https://www.syncfusion.com/downloads/support/directtrac/general/ze/CoreNTB1084524682
If this post is helpful, please consider Accepting it as the solution so that other members can locate it more quickly.
Udhaya Kumar D
Thank you, sorry for the delay.
However, I have an error on the reference "_ej2_base__WEBPACK_IMPORTED_MODULE_0__" (is not defined).
Do I need to add any particular reference?
Best regards,
Massimo
Hi Massimo,
We were able to reproduce your reported issue. The error happened due to using webpack to add the attribute. Now, modified it by adding attributes using the base method.
We suggest referring to the below code and sample to solve your problem.
Index.cshtml
<script> ej.inputs.NumericTextBox.prototype.modifyText = function () { if (this.value || this.value === 0) { var value = this.formatNumber(); var elementValue = value; this.setElementValue(elementValue); ej.base.attributes(this.element, { 'aria-valuenow': value }); this.hiddenInput.value = this.value.toString(); if (this.value !== null && this.serverDecimalSeparator) { this.hiddenInput.value = this.hiddenInput.value.replace('.', this.serverDecimalSeparator); } } else { this.setElementValue(''); this.element.removeAttribute('aria-valuenow'); this.hiddenInput.value = null; } } </script> |
https://www.syncfusion.com/downloads/support/directtrac/general/ze/CoreNTB1084524682
Regards,
Udhaya Kumar D