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.
I was trying to hide the parent table header and not the child table header. To solve this problem, I set the label height and width to zero for all the visible columns in the parent table. For example:
<infraDp:FieldLayout Key="ToadInfo"> <infraDp:FieldLayout.Fields> <infraDp:Field Name="ToadKey" Label="Shift" Width="75"> <infraDp:Field.Settings> <infraDp:FieldSettings LabelHeight="0" LabelWidth="0"/> </infraDp:Field.Settings> </infraDp:Field> <infraDp:Field Name="ToadDesc" Label="Description" Width="*"> <infraDp:Field.Settings> <infraDp:FieldSettings LabelHeight="0" LabelWidth="0"/> </infraDp:Field.Settings> </infraDp:Field> <infraDp:Field Name="IsActive" Visibility="Collapsed" /> </infraDp:FieldLayout.Fields></infraDp:FieldLayout>
I would also like to a solution for this problem, please help.
I have child tables using the same field layout as the root table but only want a single column header at the top. Having column headers in child tables too wastes too much space on the screen.
Hello,
Thank you for your post. I have been looking into it and I created a sample project for you with the functionality you want. Basically I created two FieldLayouts and assigned them to each Item in the XamDataGrid’s AssigningFieldLayoutToItem event handler. I created a global Style for the LabelPresneter which is applied to all the Labels instead for the one you want to show. For it I set the Labelpresenter style directly to the Field’s LabelPresneterStyle property. Please let me know if you have further questions on this matter.
Looking forward for your reply.
Thanks, but this solution creates a problem: Both field layouts are no longer in sync. If I resize the root columns, the child columns also need to resize, change their position etc. This is why I need to have a single field layout and not two seperate ones.
Hello Stefan,
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.
Thanks,
Priya
.
Or the simpler version of this feature: http://ideas.infragistics.com/forums/192363-wpf/suggestions/5589141-xamdatagrid-hide-child-table-field-headers
Hello Priya,
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.
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.
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.