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).
My data can only have 1 relationship per row - ID -> child.ParentId
- My childs are in seperate Tables, because they again can have own childs. - I generate a FieldLayout for each table including a field for its children (named of child-table).
My source data is one table referencing itself with ParentID -> ID. Its nested depth is dynamically. (It can be several levels)
Any hints on this?
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. :)
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
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;
I attached the example project.
The crux of the matter is, i need a different single relation for every row.
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?