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
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.
Hello Daren,
Just checking if resolve your issue or if you require any further assistance on the matter.
What else you could try if the masking is not solving your issue is directly to manipulate the value of the cell. You could handle _AfterCellUpdate and put the following code:
if (e.Cell.Column.Key == "value" && !string.IsNullOrEmpty(e.Cell.Value.ToString()))
{
string s = e.Cell.Value.ToString();
CultureInfo ci = Application.CurrentCulture;
int sepindex = s.IndexOf(ci.NumberFormat.CurrencyDecimalSeparator);
if (sepindex > 0 && s.Length - sepindex > 3)
decimal d = decimal.Parse(e.Cell.Value.ToString());
e.Cell.Value = Math.Round(d, 2);
}
Let me know if you have any further questions.
Hi Darren,
This code is very hard to read because of the formatting. But EditorToOwner controls the transition of the value from the editor (think of this as the cell in the grid) to the owner (which is the data source field). So this seems like it's exactly what you need. I can't see any reason why that would not work, unless there's something wrong with your data filter.
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
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.