HI All,
I have question
For Example
if i have 4 tables A,B,C,D
A is the parent to B.
C and D are the childs of B
how can i enable or disable the the fields layouts for the C and D depending on the count of the data or using the some field values of the data in the XamDatagrid (Parent to child relationship)?
Thanks
Prakash
Hello Prakash,
First thing that comes up in my mind is to handle the RecordExpanding event and check the fieldlayout and other conditions that you might have and cancel it if needed.
The other thing is control the ExpansionIndicatorDisplayMode of the fieldlayout in the FieldLayoutInitializing event:
For example:
void xamDataGrid1_FieldLayoutInitializing(object sender, Infragistics.Windows.DataPresenter.Events.FieldLayoutInitializingEventArgs e)
{
if (xamDataGrid1.FieldLayouts.Count > 1)
e.FieldLayout.Settings.ExpansionIndicatorDisplayMode = ExpansionIndicatorDisplayMode.Never;
}
Hope this helps.
Hi Alex,
what you said was right but for my scenario
i dont understand how it works.
i have attached an image of my grid.
My Scenario is Table B has 5 Child Tables and
in the xaml i have made those 5 tables as fields in my table B Fieldlayout.
Even though if for a B record there no related record with all child tables it shows the expander for all the 5 child tables.
I wanted to disable the field loyouts or the expander for the child table layout which does not contain data each time.
I think if you see the image you could understand the scenario.
Prakash,
If you have no records in a particular fieldlayout, and you do not want the ExpansionIndicator to show, you have to set the ExpansionIndicatorDisplayMode to CheckOnDisplay. This will evaluate the visibility of the Expansion Indicator and will not display it, if there are not records in that layout.
If this is not the case, you have to go for the FieldLayoutInitialized event. For example, I have tested this with the NWind DataBase, and this is what I am getting with the code snippet from my last post:
You can see, that there are no records in the Employee field layout and no indicator is shown (ExpansionIndicatorDisplayMode.CheckOnDisplay).
The Orders layout has no indicators as well, because of handling the FieldLayoutInitialized event.
HI Alex,
Thanks for the answer
I tried the way you suggested me and it works for me now.
But only thing is when i hide some field layouts it create's some empty space below each parent record.
I have attached the output image.
And also in your example how can you disable the header of the field layout which do not have records.( in your example it is Emplyees)
I am not sure why the empty record is shown. I am not able to reproduce this with my sample. Regarding the header, it is the ExpandableFieldRecordHeaderDisplayMode. You can take a look at the built-in options for this, but you would have to handle that manually if you want to hide it.
Thats fine.I will try it and let you know if get it done.
Thanks for the help.