When using a hierarchical object I get an unwanted effect.
The parent object (Document) has for example three childs (DocumentLines). When expanding every line get an own FieldLayout.
The FieldLayoutInitialized event is triggered multiple times.
When using the FieldlayoutIndex 0 and 1 only the parents and one Child are displayed.
Also in the field chooser multiple Fieldlayouts are displayed.
What could cause this behaviour?
regards
Perfect, thanks for your help Rob.
Ill have to create an auto expand function but thats it for now.
dataGrid.FieldSettings.ExpandableFieldRecordHeaderDisplayMode = ExpandableFieldRecordHeaderDisplayMode.NeverDisplayHeader;
Hi Patrick,
I believe you can hide that header element by setting the ExpandableFieldRecordHeaderDisplayMode property to NeverDisplayHeader. This property is located in XamDataGrid.FieldSettings.
www.infragistics.com/.../infragisticswpf.datapresenter~infragistics.windows.datapresenter.expandablefieldrecordheaderdisplaymode
Dear Rob,
thanks for your clear explanation.
What I do is create XAML by C# code. So I dont have XAML to define in code.
My code changed the fieldLayout of a field somewhere deep in some old method. That caused the strange behaviour (part 1) but still I have in this case multiple field layouts.
I created a new example using an other class and this works just fine. Have to investigate this case further.
With the new class it works fine only I get an unwanted side effect. There appears a header what I dont want in my view. Is there any way to hide this programmatically (C#)?
// parent class public class Payment { public PaymentMatchCollection PaymentMatchLines { get; set; } } // child class public class PaymentMatch { public DateTime DueDate { get; set; } public decimal TotAmntIncl { get; set; } public decimal TotOpenAmntIncl { get; set; } }
Regards Patrick
Still not really sure what is going on in your application. I built my own to try and reproduce this but I haven't had any luck. I only see two FieldLayouts being initialized. One for the parent layout and one for the child layout. Based on the class structure defined in your last update here is what my sample data looks like:
// parent class public class SalesDelivery { public string Pakbonnr { get; set; } public string Referentie { get; set; } public List<SalesDeliveryLine> Lines { get; set; } } // child class public class SalesDeliveryLine { public double Rgl { get; set; } public string Omschrijiving { get; set; } }
I left out the base classes as I didn't think they were necessary for this test. Here is how I create the data:
List<SalesDelivery> datasource = new List<SalesDelivery>(); datasource.Add(new SalesDelivery { Pakbonnr = "SD160005", Lines = new List<SalesDeliveryLine>() }); datasource.Add(new SalesDelivery { Pakbonnr = "SD160006", Lines = new List<SalesDeliveryLine>() }); datasource[0].Lines.Add(new SalesDeliveryLine { Rgl = 10, Omschrijiving = "Sticker RAL 2009" }); datasource[0].Lines.Add(new SalesDeliveryLine { Rgl = 20, Omschrijiving = "Beplakken reclame bord" }); datasource[0].Lines.Add(new SalesDeliveryLine { Rgl = 30, Omschrijiving = "Geef omschrijiving in" }); datasource[1].Lines.Add(new SalesDeliveryLine { Rgl = 10, Omschrijiving = "Sticker RAL 2009" }); datasource[1].Lines.Add(new SalesDeliveryLine { Rgl = 20, Omschrijiving = "Beplakken reclame bord" }); datasource[1].Lines.Add(new SalesDeliveryLine { Rgl = 30, Omschrijiving = "Geef omschrijiving in" });
For the XamDataGrid itself I tried manually creating the FieldLayouts in XAML and letting it autogenerate them but both approaches seem to work correctly. Here is what my XAML looks like:
<igDP:XamDataGrid x:Name="datagrid" DataSource="{Binding}"> <igDP:XamDataGrid.FieldLayouts> <!-- Parent layout --> <igDP:FieldLayout> <igDP:Field Name="Pakbonnr"></igDP:Field> <igDP:Field Name="Referentie"></igDP:Field> <!-- This tells the layout that it has children --> <igDP:Field Name="Lines"></igDP:Field> </igDP:FieldLayout> <!-- Child Layout --> <igDP:FieldLayout> <igDP:Field Name="Rgl"></igDP:Field> <igDP:Field Name="Omschrijiving"></igDP:Field> </igDP:FieldLayout> </igDP:XamDataGrid.FieldLayouts> <igDP:XamDataGrid.FieldLayoutSettings> <igDP:FieldLayoutSettings AutoGenerateFields="False"/> </igDP:XamDataGrid.FieldLayoutSettings> </igDP:XamDataGrid>
The code you showed for FieldLayoutInitialized seems to be calling an InitFields method. What does this method do exactly? Just curious if it is somehow causing the event to fire multiple times. I did attach my sample application here so can you modify it to reproduce your issue and then send it back to me?
3276.FieldLayoutInits.zip
Hi Rob,
thanks for your reply.
See below the classes and inheritance. To show all the props we need a few pages ;) So I left them as is.
The datasource is a Collection of SalesDelivery's. The Childs are a collection of SalesDeliveryLines.
I see the application triggering the Event FieldLayoutInitialized for each index. Also each index of the SalesDeliveryLine where each object has the same properties.
private void dataGrid_FieldLayoutInitialized(object sender, Infragistics.Windows.DataPresenter.Events.FieldLayoutInitializedEventArgs e) { //First we set all the fields Hidden... foreach (Field field in e.FieldLayout.Fields) { field.Visibility = Visibility.Collapsed; field.Settings.AllowHiding = AllowFieldHiding.Never; } InitFields(e.FieldLayout); }
Cannot find out why the FieldLayoutInitialized is triggered and why it creates a new layout each time.
_listTab.xamDataGrid.FieldLayoutInitialized += new EventHandler<Infragistics.Windows.DataPresenter.Events.FieldLayoutInitializedEventArgs>(dataGrid_FieldLayoutInitialized);
Hope some of you have an idea to help ;)