Hello,
The following article implies the DataPresenter supports heterogeneous data because it supports multiple field layouts:
http://help.infragistics.com/Help/NetAdvantage/WPF/2012.1/CLR4.0/html/xamData_Hierarchical_Heterogenous_and_Free_Form_Data_Structures.html
While this is true, it doesn't seem like the XamCalculationManager supports this when using a XamDataGrid. When using a formula that references a bound field in one of the layouts, an exception is thrown when initializing the calculation references. There doesn't seem to be any way to get this to work, probably because it is getting a type descriptor for a known type as opposed to the type descriptor for the type of object referenced by a record with that field layout.
For example, to support a XamDataGrid with heterogeneous records, I would assume it is possible to bind to a datasource where the Item may be some base class and after assigning a layout to a item in the datasource, only then would the bound fields be mapped to the properties of the object instance. I am not sure how else you could support heterogeneous records. With this assumption, I would expect that calculation references would only be determined once the layout was known.
However this does not seem to be the case. It appears that if the data source object type does not have the properties that are bound fields and referenced in formulas, the calculation manager will throw an exception.
Is this working as intended? How can you possibly support heterogeneous objects and multiple layouts if the formulas in one of the layouts enforce a homogeneous data model?
I am using build 2107 of Infragistics WPF 12.1 by the way.
Hi emarkunger,
I've looked at your sample and I was able to reproduce the issue. I've asked our engineering staff to examine this further so I've logged this behavior in our internal tracking system with a development ID of 132221. I've also opened up a case for you that you can use to track this development issue. The case number is CAS-109928-T0R4L3. Once a fix or other resolution is available you will be notified automatically through the case.
I want to make it clear that I am not asking how do I refer to a field in a particular layout. This was never the purpose of my post. I am trying to let you know that there is an issue with the calculation manager trying to resolve calculation references when a XamDataGrid has multiple layouts where each layout may not have all fields. I have modified the IGDataGrid VS project in the NetAdvantage 2012.2\WPF\Samples\CLR4.0\Infragistics.Samples.WPF solution to try to reproduce the error I was seeing. I have attached a zip file with the project. You can unzip the attachment and replace the IGDataGrid project in the sample solution to view a NullReferenceException being generated while trying to resolve a calculated field reference. You will have to set your Exceptions to break when the NullReferenceException is thrown since it is caught in the calculator code somewhere. You will see that I have two layouts in the project. One layout has a calculated unbound field that references a field that only exists in the same layout. Can you debug why the NullReferenceException is being thrown? To load the grid, select the xamDataGrid / Data / Object Data Binding sample. I don't see anything wrong with the xaml.
Hello Edwin,
The following XAML can be applied when referencing formulas in multiple layouts:
<TextBlock x:Name="FooTextBlock" ig:XamCalculationManager.CalculationManager="{StaticResource CalculationManager}"> <ig:XamCalculationManager.ControlSettings> <ig:ControlCalculationSettings Formula="[//refidofcalcadapter/layout1(0)/Foo]"/> </ig:XamCalculationManager.ControlSettings></TextBlock>
This references the first record of an UnboundField with ReferenceId "Foo":
<igDP:UnboundField.CalculationSettings> <igDP:FieldCalculationSettings Formula="round([comp]/[att]*100,2)" ReferenceId="Foo"/></igDP:UnboundField.CalculationSettings>
In the FieldLayout sets the CalculationReferenceId that is referenced in Formula:
<igDP:FieldLayout CalculationReferenceId="layout1">
Let me know if I can provide any further assistance.
I am aware of that. The bug I am trying to inform you about is that the XamCalculationManager is trying to create a reference to //refidofcalcadapter/refidoflayout/field for a record that is not in the layout with refidoflayout. For example, I have layout1 and layout2. layout1 has a field called Foo. layout2 does not have any formulas and does not have Field Foo. An unbound field Foobar in layout1 is referencing field Foo in layout1 using a formula.
The bug is that the calculation manager tries to create a reference for //refidofcalcadapter/layout1/Foo in the record assigned to layout2. That is a clear bug. I don't even have any formula in layout2 and the calculation manager is trying to create references to layout1 for unbound formulas that don't even exist in layout2.
The exception thrown is index out of range because it tried to use index -1 when it can't find field Foo in layout2. Please reproduce and document the bug so your team can fix this. This is a show stopper in supporting multiple layouts in a XamDataGrid that uses the XamCalculationManager.
As far as referencing fields from multiple layouts the Formula property is set from the CalculationReferenceId in each FieldLayout and from the ReferenceId in DataPresenterCalculationAdapter and CalculationSettings.