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,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.
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 { }
As I said in my previous comment, I was able to get this hierarchical data to display correctly but I'm having a problem selecting rows within my XamDataGrid when there is a hierarchy of records displayed. I set the 'SelectionTypeRecord' property in my FieldLayoutSettings to "Extended" and I'm able to multi-select child records in any of my top-level records. But once I select multiple records under one parent node, I can’t select any other child records in the other nodes. What am I missing here? Anyone have any ideas?
I have also tried to set the SelectionTypeRecord property of the child Layout in the FieldLayoutInitialized method of XamDataGrid like below but of no use.XamDataGrid1.FieldLayouts[1].Settings.SelectionTypeRecord = Infragistics.Windows.Controls.SelectionType.Extended;XamDataGrid1.FieldLayouts[1].Settings.SelectionTypeField = Infragistics.Windows.Controls.SelectionType.Extended;XamDataGrid1.Records.FieldLayout.Settings.SelectionTypeRecord = Infragistics.Windows.Controls.SelectionType.Extended;
Hi Jackie,
I'm having the same problem. I couldn't find a way to fix this in my xaml code, but was able to work around this in source code. I created an event handler for the InitializeRecord event as shown below:
{ .... this.myDataGrid.InitializeRecord +=new EventHandler<Infragistics.Windows.DataPresenter.Events.InitializeRecordEventArgs> (myDataGrid_InitializeRecord);}
void myDataGrid_InitializeRecord(object sender, Infragistics.Windows.DataPresenter.Events.InitializeRecordEventArgs e){ if(! e.Record.HasChildren) e.Record.ExpansionIndicatorVisibility = Visibility.Collapsed;
}If you end up finding a better way (especially in xaml), please share with the rest of us...Ramiro
Hi,
I have another problem. The plus/minus will show up no matter whether there are sub items or not. How to hide them when there is no sub items?
Great, thanks a lot.
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"/>