Hello,
what is the simplest way to assign different datatemplates for the top row of a hierarchy and a different one for the child records?
I have seen several approaches eg. TemplateSelector or to assing the style on loaded Event.
Thanks
Niko
Nikolaus,
Assuming your question is on having a different template for parent rows vs what the child uses and your parent and child records have different schemas you can just create multiple FieldLayouts and the correct one will automatically be used. If your Parent and Child records have the same schema or you wish to be able to specify a FieldLayout to use on a record by record basis, you can use the AssigningFieldLayoutToItem event.
Hello Alan,
the parent row uses the FieldLayout <igDP:FieldLayout Key="Baustellen"> and the child records use <igDP:FieldLayout Key="Ressourcen">.
A small set of columns are defined in XAML, the majority (= one column per day) is created in code behind. For that reason I assume that the AssigningFieldLayoutToItem event is my friend.
I will work with this event and come back in case new Questions arrise.
Niko,
If the columns are added to the existing layout and the list that the XamDataGrid is bound to has all of the columns where the schema matches, it should still find the correct schema as along as they are unique between "Baustellen" and "Ressourcen". In this scenario you shouldn't need to use AssigingFieldLayoutToItem.
Assuming that the one column per day is dynamic and the grid displays different data for different ranges, are you dynamically creating an object that matches the schema to display data in the grid or are you adding unbound columns and manually setting the values in the grid?
What does the data per day represent? Would a pivot grid better meet your needs where data can be aggregated by date?
on my further search I found following thread:
https://www.infragistics.com/community/forums/f/ultimate-ui-for-wpf/80718/can-i-choose-a-field-layout-based-on-data-type
Does this mean that the name of the FieldLayout is linked to the class name of the items? Or to the propertyname of the itemssource?
Hello Niko,
FieldLayout is linked to the DataSource. It is not linked to class name of the items or to a specific property name in the ItemSource. I have attached a simple sample that demonstrates how different FieldLayouts can be created for parent and child rows with different schemas. For example, you can add parent and child FieldLayouts like this to achieve this:
<ig:XamDataGrid x:Name="xdg" DataSource="{Binding Data}" AssigningFieldLayoutToItem="xdg_AssigningFieldLayoutToItem"> <ig:XamDataGrid.FieldLayoutSettings> <ig:FieldLayoutSettings AutoGenerateFields="False"/> </ig:XamDataGrid.FieldLayoutSettings> <ig:XamDataGrid.FieldLayouts> <ig:FieldLayout Key="Parent"> <ig:Field Name="ID"/> <ig:Field Name="Name"/> <ig:Field Name="Age"/> <ig:Field Name="Date"/> <ig:Field Name="Children"/> </ig:FieldLayout> <ig:FieldLayout Key="Child" ParentFieldName="Children"> <ig:Field Name="ID"/> <ig:Field Name="Age"/> </ig:FieldLayout> </ig:XamDataGrid.FieldLayouts> </ig:XamDataGrid>
Please review the sample and let me know if you have any further questions.
XDGAssigningFieldLayoutDemo.zip
thanks a lot for the example and explanation. It works fine.