Hello,
I am using Infragistics 12.1 release 2107. I am having a problem getting an unboundfield with a formula to update when the cells referenced in the formula are updated. My cell values are nullable decimals and I do not use the native multiply and subtract operators in the formula because they assume a null calculation value is 0 instead of null when a bound decimal? property value is null. I had to write my own custom formulas for mutliply and subtract that use decimal? null instead of 0 when a calculation value is null. My object that I am binding the XamDataGrid is an ObservableCollection of lets say Foo. Foo has the following public properties:
FutureMarketData FutureMarketDatadecimal? BidPricedecimal? ConversionFactor
Bound Fields:
BidPriceConversionFactor
Unbound fields
Basis with FieldCalculationSettings Formula=="decmultiply( 32, subtract( [BidPrice], decmultiply( [FuturePrice], [ConversionFactor] ) ) )" FuturePrice with BindingPath=FutureMarketData.LastPrice
My object Foo implements INotifyPropertyChanged and issues and raises the property changed event whenever a property changes. FutureMarketData also implements INotifyPropertyChanged and raises the property changed event whenever a property changes.
The unbound column in the XamDataGrid sometimes has a null value even though the bound and unbound fields in the row all have values. If I change the formula to be "decmultiply( 32, subtract( [BidPrice], [FuturePrice] * [ConversionFactor] ) )" then the Basis column will not be null however the value in Basis will be wrong because [FuturePrice] * [ConversionFactor] will be 0 even if FuturePrice is null.
When I push a button, I retrieve the future market data and the following property changed events are raised in the following order for one of my objects whose Basis cell value is null even though the bound and unbound cells used in the formula are not null:
If the notify property changed events are raised in this order then the Basis column will have a non-null value:
BidPrice subtract is called with arguments 99.9296875 and null as expected, returning nullConversionFactor (value is 0.9016 when notified) - FutureMarketData.LastPrice has a value at this time but event for FutureMarketData has not been raised yetdecmultiply is called FutureMarketData (FutureMarketData.LastPrice is 110.171875 when notified)decmultiply or subtract is never called again for this row
After this is done. The BidPrice, FuturePrice, and ConversionFactor cells all have values shown but the Basis cell is null.
But if I raise the events in this order then the Basis cell will have a good value - not null.
BidPricesubtract is calledFutureMarketDatadecmultiply is calledConversionFactordecmultiply is calledsubtract is calleddecmultiply is called to return the final value
Why does the order the notify events are raised determine whether the cell is properly updated or not. If the decmultiply function call is using unbound field FutureMarketData.LastPrice and bound field ConversionFactor, then it should be called every time the following notify property changes are raised:
FutureMarketDataLastPrice on object FutureMarketDataConversionFactor
in any order called but this does not seem to be the case. I have attached a file with the Function_Subtract and Function_DecimalMultiply custom functions. ToNullableDecimal is an extension method which does as you might expect, returning true when the CalculationValue is a decimal or null.
<igDP:UnboundField Name="Basis" Label="{Binding BasisLabel, Source={StaticResource BondViewModel}, Mode=OneWay}" DisallowModificationViaClipboard
="True" >
<igDP:UnboundField.CalculationSettings
>
<igDP:FieldCalculationSettings Formula
="decmultiply( 32, subtract( [BidPrice], decmultiply( [FuturePrice], [ConversionFactor] ) ) )" />
<!--<igDP:FieldCalculationSettings Formula="decmultiply(32,subtract([BidPrice],[FuturePrice] * [ConversionFactor]))" TreatAsTypeName="Nullable<Decimal>" />-->
</igDP:UnboundField.CalculationSettings
<igDP:UnboundField.Settings
<igDP:FieldSettings EditorType="{x:Type igEditors:XamNumericEditor}" EditorStyle="{StaticResource BasisFormat
}" />
</igDP:UnboundField.Settings
</igDP:UnboundField
Thank you for your post. I have been looking into it, but without a sample where this issue is reproduced, I am not able to conclude what can cause this behavior, so could you please send an isolated sample project, where the issue is reproduced, so I can investigate it further for you.
Looking forward for your reply.
It's very hard for me to find time to make an isolated sample right now. Seems that the bug would be around the fact that when using a unbound field with something like Foo.Bar that a formula using the unbound field is not calculated when Foo is originally null and then set along with the property change event being raised for "Foo" but not followed by a property change event for Bar.
Could you modify one of your samples that uses custom formulas to use an unbound field like that. For example, if binding the XamDataGrid to an ObservableCollection of FooBar where FooBar has a property Foo that is an instance of an object that has a Bar property. I realize this won't guarantee the problem can be reproduced, I just don't have time to create such a sample myself right now because of deliverables I am currently working on now.
I am just checking the progress of this issue and was wondering if you managed to achieve your goal or if you need any further assistance on the matter.
No I was unable to isolate the issue. I believe it must manifest perhaps only when a certain complexity of formulas. I was unable to reproduce using your project unfortunately. I have moved on to struggling with other calculation manager issues for which I have started another thread.