Hi,guys,my data grid's datasource is hierarchical data, and I needs to define the FieldLayout in Xaml file,how can I define both the parent records and child record's fieldlayout?
Hi Jackieliu,
let's say you want to show only 2 levels, you need to define 2 FieldLayouts.
<FieldLayout Key="Network">
<Field Name="NetworkProperty1"/>
<Field Name="NetworkProperty2"/>
<Field Name="Domains"/> *name of the property that returns you IEnumerable that contains next level of data.*
</FieldLayout>
<FieldLayout Key="Domain">
<Field Name="DomainProperty1"/>
<Field Name="DomainProperty2"/>
Joe,
I have a hierarchical structure like below. When I bind an instance of NetWork to the XamDG, all these 4 levels will be displayed by default with AutoGenerateFields="True". What if I want to show only 2 or 3 level? I set AutoGenerateFields="false" and defined 2 FieldLayouts, it didn't work as intended. Only top level was shown. Do you have any idea on that?
Thanks,
Jackie
public class NetWork { public ObservableCollection<Domain> Domains { get; set; } } public class Domain { public ObservableCollection<Machine> Machines { get; set; } } public class Machine { public ObservableCollection<Service> Services { get; set; } } public class Service { public ObservableCollection<Child> Children { get; set; } } public class Child { }
Hi,Joe, thanks for your reply, it can work if the datasource is dataset, but how about the datasource is ObjectDataProvider? I tried this type datasource, it seems defining both parent field layout and child field layout can't work.