I'm working with a WebDataGrid and I need to be able to add values to a database that has a datatype of Decima(4,3). In other words, the values must be something like 1.234, 0.128, 9.001, etc. If I try to add something like 11.120 or 32.15, I get an exception.
Is there a way to apply a mask (or something similar) to a NumericEditorProvider that will limit the user's input to only allow for a single whole integer? I could use validation but that seems like a kind of round about way of doing it.
Adam,
Apologies for the late reply.
Yes, you could achieve the desired scenario.
Attach to textChanged event:
<ig:NumericEditorProvider ID="UnitPriceEditorProvider" EditorControl-ClientEvents-TextChanged="textChanged"> </ig:NumericEditorProvider>
And the code should be similar to this:
function textChanged(sender, args) { var number = parseInt(args.get_text()); if (number === sender.value) { return; } else if (number <= -10 || number >= 10) { sender.set_value(sender.value); } }
Please let us know if you need further assistance.
Hi Tihomir,
Thanks for your response. However, you misunderstood my question. I am not looking to limit input to a single whole integer. I already know how to do that; it's super simple. I'm trying to limit a decimal to only allow for a single whole integer followed by up to three decimal places. As I said, "the input must be something like 1.234." I know how to limit the decimal places already. What I'm trying to do is limit the non-decimal places. Here are some examples to further clarify:
1.234 - OK
0.44 - OK
9.8 - OK
9.999 - OK
0.001 - OK
4 (which would be converted to 4.000) - OK
10.023 - Bad
98.51 - Bad
17 (which would be translated to 17.000) - Bad
Hello Adam,
Thank you for contacting us.
I do not get excpetion when updating the value using NumericEditorProvider. If you want to allow only integers, you should set EditorControl-MaxDecimalPlaces="0" to the editor.
Here is a working project demonstrating the desired scenario - https://filetransfer.infragistics.com/public.php?service=files&t=0b6742d718cdb31d4c9abc32d6fb7e90.
You could send us a project demonstrating your exception if you want us to investigate further.
Best Regards,Tihomir IlievSoftware DeveloperInfragistics, Inc.