Hello,
im using XamDataGrid hierachical through binding its DataSource to a hierachical DataSet, and provide they FieldLayout + RelationField for each FieldLayout/Table, dynamically. (I generate the grid all code-behind, no xaml. (Dynamic relations & columns.))
I dont want the relation headers "relation6" / "relation7" / ..
My problem is, i add multiple child-relations for a table - used by different rows. The grid now displays every relation for every row, even if its empty for this row. How should i provide the relations? Or Hide the relation-groups/headers? (hide relation field?)
GreetingsiA. Kits
Hi Joerg,
If I'm understanding this correctly, you just want to hide the relations that have no child records? This relations are appearing because a Field has been defined for that relation. I presume that you are using auto generated fields? You can hide these relations by using the following style:
<Style TargetType="{x:Type igWPF:ExpandableFieldRecordPresenter}"> <Style.Triggers> <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Record.HasChildren}" Value="False"> <Setter Property="Height" Value="0"/> </DataTrigger> </Style.Triggers></Style>
Those relations that you see are called ExpandableFieldRecordPresenters. When there is children data you would normally be able to expand the relation and see the child data but if there are no children it does not hide the relation itself. You can do this with the above trigger. If there are no children in the ExpandableFielRecordPresenter then it will set the height to 0. We set the height to 0 because you can't actually set the Visibility to Collapsed. If you do, the record space will still be shown.
Hi Rob,
thanks for your fast response.
i dont want the ExpandableFieldRecordPresenters "relation6" / "relation7".. displayed at all. Also not for rows which has children.
I want it like you can see in the first hierachical level of my screenshot - the expansionindicator directly before the row, without any additional header "RelationName".
PS: I dont use auto generated fields. I generate them myself. I use KeyMatchingEnforced (and layout.Key = table.TableName).
I don't think I understand all that well. I think it mostly has to do with the fact that I'm not very good with DataTables :(. Would it be possible for you to send me a sample of what you have so far and I can try to make it work the way you need it? It would be nice to see how your DataTable and FieldLayouts are generated.
I'm working on an example project. By the way, can you see my screenshots?
"When there is more than one Field it displays these presenters so the user can tell which is which."
Yes i understand this, but in my case 1 row can only use 1 relation, so there is no need for the user to know which relation is used. Can i somehow turn this display feature off?
I attached the example project.
The crux of the matter is, i need a different single relation for every row.
Here is what I think you need to do. Just set these two properties and as long as your tables are configured such that each row only has 1 relation of it's own then it should display the type of grid you need.
dataGrid1.FieldSettings.ExpandableFieldRecordHeaderDisplayMode = ExpandableFieldRecordHeaderDisplayMode.NeverDisplayHeader;dataGrid1.FieldSettings.ExpandableFieldRecordExpansionMode = ExpandableFieldRecordExpansionMode.ExpandAlways;
that's it!
Why was that so hard to archieve.. :/ Any hints where i could have searched for it in the documentation?
Thanks for your help.iA. Kits
There is mention of those properties here but if I were to read that I wouldn't associate it with what you were trying to do. And honestly I wasn't aware of those properties until a colleague of mine pointed them out to me so he's the real hero here. :)