I have hierarchical data. There is a one to one relationship between my parent and child. My requirements dictate that only the child be displayed in the grid. What is the best way to accomplish this with xamDataGrid?
My first approach was to create a new DataRecordPresenter style that has a new Template and set that on the grid. However I get a null exception during runtime and the only information from that exception is a stacktrace that goes deep into Infragistics code. Also, I am not sure what to put in the Template.
If the child is exposed as a property off the parent then the easiest way is to use UnboundFields (one for each property of the child that you want to see), setting the UnboundField's BindingPath property to "(xxx).yyy" where xxx is the name of the property exposed off the parent record which returns the child record and yyy is the name of a property on the child.
I hope this helps.
I tried the solution you proposed and it works for the regular fields, but when I use it for a ICollection field in order to make a sub-level group appear, it does'nt seem to work.
In this example, the AssetMixClassRaw.Positions is a Collection. When I tried it, I had a column named Positions instead of a sub-level group. What did I do wrong?
<igDP:XamDataGrid.FieldLayoutSettings>
<igDP:FieldLayoutSettings SelectionTypeRecord="Extended"
SelectionTypeCell="Extended"
</igDP:XamDataGrid.FieldLayoutSettings>
<igDP:FieldSettings ExpandableFieldRecordExpansionMode="ShowExpansionIndicator"
<igDP:FieldLayout>
<igDP:UnboundField Label="MaturityValue" BindingPath="AssetMixClassRaw.MaturityValue"/> <igDP:UnboundField BindingPath="AssetMixClassRaw.Positions"/>
<igDP:FieldLayout.Settings>
</igDP:FieldLayout.Settings>
<igDP:Field Label="{x:Static p:Resources.AccountNumberCaption}" Name="AccountNumber" />
</igDP:XamDataGrid.FieldLayouts>
Just set the IsExpandable property on the UnboundField. e.g.
<igDP:UnboundField BindingPath="AssetMixClassRaw.Positions" IsExpandable="True"/>
I tried your solution, it's better, but it steel does'nt work.
Now, I see an expandable icon in the first left column, wich is wath I wanted. But when I expand it, all I see is the title of the sub-level group : "Positions" and the term "(Collection)" under. The data expected is not shown. Can you help me again?
Try setting the DataType of the UnboundField to your collection type.
Hi,
I tried your solution, but have'nt got it to work write yet.
I have an other question on the same topic. If I add a Field of type double, the value is justified on right and is round to 2 decimals automaticaly. If I add a UnboundField of type double, the value is justified on the left et no rounding is done. Since UnboundField inerit from Field class, I assumed that it would behave the same way. Would'nt it be a good idea. And it would work the same way for the expandable fields.
Karine
Hmmm, I'm sure sure what is going on here. Any chance of posting a small sample that demonstrates it here so I can take a look?
You should be able to specify it the same way, e.g. if your property returns an ArrayList it would be:
If it is a custom class of yours you would have to map the local namespace that contains the class. Note: if you are deriving from a generic class like ObservableCollection<T> I don't think there is any way of specifying that in xaml. In this case, you would either have to set the DataType of the UnboundField in code by wiring up the FieldLayoutInitialized event of derive a class from ObservableCollection<T> so you could specify it in xaml.
Tanks for your anser. I was just making a suggestion. Would'nt it be a good idea to enable the possibility to use 1 for 1 object relationship like regular fields?
By the way, I did'nt figured out the way to specify the DataType when its a Collection.
Tanks.
Using an Unbound field you would need to specify the DataType to pick up the default formatting and the approriate editor, e.g.:
<Window ... xmlns:sys="clr-namespace:System;assembly=mscorlib" > ...
DataType="{x:Type sys:Decimal}"
/>
Here is 2 examples of xamdatagrid using the same object. In the first example, its a collection using the object only, in the second example, its a collection of an other object that has a 1 for 1 relationship with the same object from the first example. Both examples are supposed to display the exact same data. In the first example, I have data in the Master and Detail part of the grid, in the second example, I dont have data in the Detail part becose I have to find a way to specify the DataType. In the first example, the double values are shown justified on the right and rounded to 2 decimales, in the second example, the double values are shown justified on the right and not rounded.
Here is the first example, using Fields
http://img145.imageshack.us/my.php?image=fieldlayoutsetupla1.png
<igDP:Field Label="classe d'actif" Name="LongDescription"/>
<igDP:Field Label="Percentage" Name="Percentage"/>
<igDP:Field Label="BookValueInvestmentCost" Name="BookValueInvestmentCost"/>
<igDP:Field Label="AccruedInterestDividend" Name="AccruedInterestDividend"/>
<igDP:Field Label="AnnualIncome" Name="AnnualIncome"/>
</igDP:FieldLayout.Fields>
</igDP:FieldLayout>
Here is the second example, using UnboundField.
http://img296.imageshack.us/my.php?image=unboundfieldssc5.png
<igDP:FieldLayout.Fields>
<igDP:Field Label="classe d'actif" Name="Name"/>
<igDP:UnboundField Label="BookValueInvestmentCost" BindingPath="AssetMixClassRaw.BookValueInvestmentCost"/>
<igDP:UnboundField Label="AccruedInterestDividend" BindingPath="AssetMixClassRaw.AccruedInterestDividend"/>
<igDP:UnboundField Label="AnnualIncome" BindingPath="AssetMixClassRaw.AnnualIncome"/>
<igDP:UnboundField Label="Sous niveau Classes"
BindingPath="AssetMixClassRaw.AssetClasses"
<igDP:UnboundField Label="Sous niveau Positions"
BindingPath="AssetMixClassRaw.Positions"