Let's say I want a column for entering decimal degrees for values between -180 and 180, with decimal place precision. I might set a column as:
column.MaskInput = "{double:-3.6}";column.MinValue = -180;column.MaxValue = 180;
However, when I enter a value like 180.1, I get an error message when the cell exits edit mode:
Data Error - Unable to update the data value: Input value does not satisfy maximum value constraint.
But why did the editor allow 180.1 to be entered in the first place? That breaks the maximum value?
How do I either prevent this, or stop that Data Error message displaying so that I can put my own validation in?
Thanks
Boris, I tried that initially, but that causes a problem where you try to type a negative number and CellChange handler replaces -. with 0
I do a TryParse on the Cell.GetText when the row is committed and if it is invalid then I set the Cell.Value to 0
Thanks for your help.
Hello,
I am glad to hear that you were able to solve this. Could you please clear out what do you want to happen when the contents are deleted completely? If you want for example the cell to have 'Value' 0 - you could attach an 'else' statement after the first if ( "if (isDecimal)..." ) and do something like this:
if (isDecimal) { ...................... } else { e.Cell.Value = 0; }
Please let me know if that is what you are looking for, I hope it helps.
Thanks Boris, the zipped sample explains the full story. Makes sense now.
One problem remains, that if you delete the contents completely and commit the row, the value is blank (null).
I've handled it in my code, but would be interested to see how you would handle it.
Sorry, missed the complete sample post above. Will take a look now! Sorry for confusion.
Thanks Boris, but I still don't follow. First off, I think you need to read my other reply further up, where I try your code but find that it cannot handle entering negative numbers or deleting all text in a cell.
In all these scenarios, I am not exiting edit mode, i.e.:
I am just typing text into the cell, and at no point am I exiting edit mode. The validation is occuring on cell change.
When you say try your example, do you mean add the CellChange event to my code which includes the maxvalue and maskinput set on the column, as per my original post? Or are you saying to remove the maxvalue and maskinput and just use your CellChange instead?
Perhaps a complete sample is necessary?