Hello,
I have a decimal column which I format using the column.format to 2 decimal places. I can see that this changes the text but not the underlying value. What
is the best way to round the underlying value? My database is crashing trying to save too many decimal places.
Do I have to use the IEditorDataFilter?
regards
Darren
Hello Darren,
What database are you using? Microsoft SQL Server automatically rounding decimal value, when scale of value is more than scale of the column. So your database shouldn’t be “crashing” if you are synchronize the type of what you insert with database type of the column where you insert.
If you want to rounding value of the cell you could use _BeforeCellUpdate event of the grid, and round cell value depends on your requirements.
Let me know if you have any further questions.
Thanks for the response Hristo. I'm using Sybase ASE 12 with the .NET Sybase drivers unfortunately. I tried using the BeforeCellUpdate but it doesn't seem to allow you to change the value.
I also tried BeforeExitEditMode but I also need to make sure that any calculated fields get rounded as well, as they will cause a crash too.
So I thought perhaps I could use the Datafilter , but so far I haven't gotten that to work.
So you want to prevent your users from entering more than 2 decimal places? In that case, you should use the MaskInput property on the column. Set it to something like:
"nnn.nn"
Hi Mike,
Whereas I can mask the input for the fields the user enters, if it results in a calculated column having more than 6 decimal places it still causes a problem.
I thought I could use the datafilter EditorToOwner to convert it but it only seems to change the Text of the cell and not the underlying value.
I thought I'd try the datafilter so I did this, which seems to update the Text but the value itself is still not updated to the new value.....
Then
.Format = BuildNumberFormatString(objLwCalcMethodDetailItem.DecimalPlaces)
EditorWithText
NumericEd.DataFilter =
DecimalPlacesConverter
Ucolumn.Editor = NumericEd
If
Public
Infragistics.Win.IEditorDataFilter
Infragistics.Win.EditorDataFilterConvertArgs) _
IEditorDataFilter.Convert
conversionArgs.Direction
ConversionDirection.EditorToOwner
_
conversionArgs.Value.GetType()
conversionArgs.Handled =
True
(conversionArgs.Value, System.Decimal)
= Math.Round(OldValue, 2)
RoundedValue
Select
Nothing
Function
End
Class
I am just checking about the progress of this issue. Did you need any further assistance on this issue? Did you solve your issue accordingly to the information that I provided you?
Let me know if you need any further assistance.
Thank you for using Infragistics Components.