Hi,
Is it possible to show a hierarchical data(another grid) on clicking of a row in a igDP:XamDataGrid?
regards
Vivek
Hello Vivek,
Thank you for your post. I have been looking through it and I attached a sample project containing a xamDataGrid with hierarchical data. By selecting a row, the child elements are expanded. Please let me know if this covers your expectations.
I am looking forward to see hearing from you.
Hi Stefan Stoyanov
Great example. That was really helpful to me!
I do have one question though. Is it possible to remove the headers from the "book-items". I have some "recursive" data that I want to display with the same headers for all rows.
Is this possible and if so, how?
Hello again,
I have been looking through your code snippet and since you have the same data objects for all levels of data the XamDataGrid maps the first suitable FieldLayout in its FieldLayout collection. As a result the other layouts are not used at all, along with their settings. I can suggest you handle your AssignFieldLayoutToItem event in order to manually specify how your FieldLayouts are used. You can assign keys to your layouts and use a code snippet like this one:
FieldLayout resultLayout = new FieldLayout(); if (e.ParentExpandableFieldRecord == null) resultLayout = xamDataGrid1.FieldLayouts["master"]; else resultLayout = xamDataGrid1.FieldLayouts["nested"]; e.FieldLayout = resultLayout;
where the parent records get the "master" and child records the "nested" FieldLayout. Please let me know if you require any further assistance on the matter.
Thanks for your response!
I'm having some trouble with "master" and "nested". Should they be added as styles somewhere?
Also, should I return to the original XAML for the XamDataGrid (without FieldSettings tags/definitions)?
Hello,
I am sorry I haven’t been clear enough in my previous post. The “master” and “nested” are the keys of the FiledLayouts. Just set the Key properties of the layouts like this : x:Key = “master” for the first one and x:Key = “nested” for the second one. Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.
I wasn't able to use x:Key="master", only Key="master". I get the following exception when I try to build.
'Initialization of 'Infragistics.Windows.DataPresenter.XamDataGrid' threw an exception.' Line number '34' and line position '14'.
The exception refers to the first instance of <igDP:XamDataGrid.FieldLayouts>.
<igDP:XamDataGrid x:Name="MyGrid" DataSource="{Binding Calculations}" AssigningFieldLayoutToItem="MyGrid_AssigningFieldLayoutToItem"> <igDP:XamDataGrid.FieldSettings> <igDP:FieldSettings CellClickAction="SelectRecord" AllowEdit="True" /> </igDP:XamDataGrid.FieldSettings> <igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout Key="master"> <igDP:Field Name="ShortName"></igDP:Field> <igDP:Field Name="Name"></igDP:Field> <igDP:Field Name="Min"></igDP:Field> <igDP:Field Name="Prob"></igDP:Field> <igDP:Field Name="Max"></igDP:Field> <igDP:Field Name="Mean"></igDP:Field> </igDP:FieldLayout> <igDP:FieldLayout Key="nested"> <igDP:Field Name="ShortName"> <igDP:Field.Settings> <igDP:FieldSettings LabelPresenterStyle="{StaticResource MyStyle}"></igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="Name"> <igDP:Field.Settings> <igDP:FieldSettings LabelPresenterStyle="{StaticResource MyStyle}"></igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="Min"> <igDP:Field.Settings> <igDP:FieldSettings LabelPresenterStyle="{StaticResource MyStyle}"></igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="Prob"> <igDP:Field.Settings> <igDP:FieldSettings LabelPresenterStyle="{StaticResource MyStyle}"></igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="Max"> <igDP:Field.Settings> <igDP:FieldSettings LabelPresenterStyle="{StaticResource MyStyle}"></igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="Mean"> <igDP:Field.Settings> <igDP:FieldSettings LabelPresenterStyle="{StaticResource MyStyle}"></igDP:FieldSettings> </igDP:Field.Settings> </igDP:Field> </igDP:FieldLayout> </igDP:XamDataGrid.FieldLayouts> </igDP:XamDataGrid>
It seems like I am missing something. Would you please send me an isolated sample project, so I will be able to investigate your issue further.
Hello George,
The approach I suggested you works if there are different FieldLayouts for the parent and child records, so I created a sample project for you, which works with self-reference data.
Hope this helps you.
Hi Stefan,
are you sure, this style applies always to the first level? In my case I have only one FieldLayout and it IsDefault.
So by me it applies to all the levels.
Is there any other Property, that one could use for triggering?
Greets,
George
I can suggest you use the following Styles for the LabelPresenter and DataRecordPresenter:
<Style TargetType="{x:Type igDP:LabelPresenter}"> <Style.Triggers> <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self},Path=Field.Owner.IsDefault}" Value="False"> <!--Add the Setters for the LabelPresenter--> </DataTrigger> </Style.Triggers> </Style> <Style TargetType="{x:Type igDP:DataRecordPresenter}"> <Style.Triggers> <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self},Path=FieldLayout.IsDefault}" Value="False"> <!--Add the Setters for the DataRecordPresenter--> </DataTrigger> </Style.Triggers> </Style>
Which has Triggers in order to determine if the Labels and Records are from the first level or not.
I saw your sample - this is the functionality I need also.
In my case i have generic data and I use AutoGenerateFields = True; What could I do in this case? How to override the LabelPresenter and DataRecordPresenter styles only for the ChildRecords?
Looking forward to your suggestion,
When you buy a license you get both the WPF3 and WPF4 assemblies, so I assume you are looking for ver.4 in C:\Windows\assembly, where is the GAC for CLR 1, 2 and 3 and the GAC for CLR 4 is here C:\Windows\Microsoft.NET\assembly\GAC_MSIL. Please let me know if this helps you or you need further clarifications on this matter.