Hi,
I have bound XamDataGrid to a hierarchical data source and only want one column header for the root records, all expanded child table's column header is hidden, how can I achieve this? Thanks.
Did you ever find a solution to this? We have the exact same problem.
The solution we eventually reached was instead of using the child table capability in our scenario, we manually insert/remove records in the underlying data source to mimic expand/collapse behavior.
Hello Stefan,
Just add AutoGenerateFieds = false to your sample and you will notice the issue.
My requirement is to bind multi-level tree to the Xamdatagrid. I have nested Observable collection of objects of same class which I need to bind to XamDataGrid.
Previously it was giving me multiple headers for parents child rows with only 2 levels of tree therefore I tried using your solution but it doesn't work if I set AutoGeneraeFields property to false.
Using two field layouts for parent child like below(adding ChildList field in both parent-child layouts) seems to work fine, but in that case second column in my xamgrid is not aligned for Parents-child rows.
<igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout Key="GLAccounts"> <igDP:FieldLayout.Settings> <igDP:FieldLayoutSettings SelectionTypeCell="Single" SelectionTypeRecord="Single" LabelLocation="Default" AutoGenerateFields="False" ExpansionIndicatorDisplayMode="CheckOnDisplay" /> </igDP:FieldLayout.Settings> <igDP:FieldLayout.Fields> <igDP:Field Name="ReferenceAndName" Label="GL Accounts" PropertyChanged="Field_PropertyChanged"> <igDP:Field.Settings> <uc:RMFieldSettings CellValuePresenterStyle="{StaticResource cvpSubAccount}" /> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="GLAccountMappedAccountID" Label="Mapped Accounts" PropertyChanged="Field_PropertyChanged"> <igDP:Field.Settings> <uc:RMFieldSettings AllowEdit="True" EditorStyle="{StaticResource xceMappedAccounts}" EditorType="{x:Type igEditors:XamComboEditor}" /> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="SubAccountsList" /> </igDP:FieldLayout.Fields> </igDP:FieldLayout><igDP:FieldLayout Key="SubAccounts"> <igDP:FieldLayout.Settings> <igDP:FieldLayoutSettings SelectionTypeCell="Single" SelectionTypeRecord="Single" LabelLocation="Hidden" AutoGenerateFields="False" ExpansionIndicatorDisplayMode="CheckOnDisplay" /> </igDP:FieldLayout.Settings> <igDP:FieldLayout.Fields> <igDP:Field Name="ReferenceAndName" Label="GL Accounts" PropertyChanged="Field_PropertyChanged"> <igDP:Field.Settings> <uc:RMFieldSettings CellValuePresenterStyle="{StaticResource cvpSubAccount}" /> </igDP:Field.Settings> </igDP:Field> <igDP:Field Name="GLAccountMappedAccountID" Label="Mapped Accounts" PropertyChanged="Field_PropertyChanged"> <igDP:Field.Settings> <uc:RMFieldSettings AllowEdit="True" EditorStyle="{StaticResource xceMappedAccounts}" EditorType="{x:Type igEditors:XamComboEditor}" /> </igDP:Field.Settings> </igDP:Field><igDP:Field Name="SubAccountsList" /> </igDP:FieldLayout.Fields> </igDP:FieldLayout>--> </igDP:XamDataGrid.FieldLayouts>
Can you please tell me why it is not working
Thanks,
Priya
Hello Priya,
In the sample I attached to my last response ("TreeView_SelfReference_Modified.zip") the AutoGenerateFields Proeprty is set to false and there are no child labels. Please note that there are two Styles defined for the LabelPresenter and DataRecordPresenter and their Loaded events are handled. In the handlers the columns are synced and the child headers are hidden. Please let me know if you have further questions on this matter.
Looking forward for your reply.
Thank you for your reply.
I tried your solution in TreeView_SelfReference.zip folder. It generates tree view as required but it does not align second column of XamDataGrid for both parent-child columns when loaded for first time.
If you change the column alignment manually to align then it works perfect afterwards.
What should I change to have even alignment on loading. Your solution is working just fine in that case as well.
I can say that the approach used in this sample is meant to work with AutoGenerateFields set to true. If you want to hide some of the Fields you can handle the XamDataGrid's FieldLayoutsInitialized method and hide the Fields you don't want to visualize. I modified the sample to show you this approach. Also I can suggest you vote for this idea, so this functionality can be implemented in our future versions:
http://ideas.infragistics.com/forums/192363-wpf/suggestions/5988260-new-wpf-tree-grid-control
Please let me know if this helps you or you have further questions on this matter.
Sorry for late reply but I had to work on some other project for a while.
I tried the solution you provided but it still has some proble. Now, it generates all the data as expected but it shifts column layout for child records.
I tried to change MainWindow_PropertyChanged method to make it work with no luck. Is there any workaround for this.
Inserted image of the screenshot for your reference.
.