Hi,
I have a master/detail grid that uses 3 diferent layouts. The number of details completely dynamic. Sometimes, the grid does'nt take the good layout.
A FieldLayout defines the Fields (columns) contained in a particular DataRecord. When a DataRecord is created, the FieldLayouts collection is searched for an existing FieldLayout whose Fields match the DataItem's properties.
I would like to spécify the layout to use in the detail, in the definition of the field in the master layout.
That would look like :
I have a master/detail grid that uses 3 different layouts. Here is an example...
<dg:DataGrid.FieldLayouts> <igDP:FieldLayout> <igDP:FieldLayout.Fields> <igDP:Field Name="AccountNumber"/> <igDP:Field Name="Name"/> </igDP:FieldLayout.Fields> </igDP:FieldLayout>
<igDP:FieldLayout> <igDP:FieldLayout.Fields> <igDP:Field Name="ClientNumber"/> <igDP:Field Name="Name"/> <igDP:Field Name="Accounts"/> </igDP:FieldLayout.Fields> </igDP:FieldLayout>
<!--Relations--> <igDP:FieldLayout> <igDP:FieldLayout.Fields> <igDP:Field Name="LinkNumber"/> <igDP:Field Name="FullName"/> <igDP:Field Name="Accounts"/> <igDP:Field Name="Clients"/> </igDP:FieldLayout.Fields>
</igDP:FieldLayout>
</dg:DataGrid.FieldLayouts> The layout used for the master is not always the same and the number of details is dynamic. I would like to specify, in the xaml or programaticaly, the layout to use in the definition of the field ex : <igDP:Field Name="Accounts" Layout="NameOfTheLayoutToUseInTheDetail"/> Is there a way to acheive this? Thanks Karine
<
dg:XamDataGrid.FieldLayouts>
>
</
igDP:FieldLayout
<!--
Client
-->
igDP:FieldLayout.Settings
igDP:FieldLayoutSettings AutoGenerateFields="False" LabelLocation="Hidden"
/>
igDP:FieldLayout.Fields
dg:DataGridField
dg:DataGridField.Settings
igDP:FieldSettings CellWidth="16" LabelWidth="16" AllowGroupBy="False" AllowResize="False" CellValuePresenterStyle="{StaticResource elementTypeIconStyle}"
igDP:Field Name="ClientNumber"
igDP:Field.Settings
igDP:FieldSettings CellWidth="70" LabelWidth="70"
igDP:Field
igDP:Field Name="Name"
igDP:FieldSettings CellWidth="150" LabelWidth="150"
igDP:Field Name="Accounts"
Relations
igDP:Field Name="LinkNumber"
igDP:Field Name="FullName"
dg:DataGrid.FieldLayouts
Hello Karine,
As far as I know, the FieldLayout cannot be set on the Field object. Your best approach may be to programmatically set your FieldLayouts in code. Here is a high level example of the options you have available from the code-behind:
grid.FieldLayouts.Clear(); FieldLayout fl = new FieldLayout(); Field field = new Field(); fl.Fields.Add(field); fl.Fields.Remove(fl.Fields[0]);
Hope that helps.
Hi Karine -
To assign a specific FieldLayout to a data item, you can listen to the AssigningFieldLayoutToItem event on the XamDataGrid. This event is fired when the XamDataGrid is attempting to associate a FieldLayout with an item from the DataSource. The event args for this event exposes a couple of properties that your event handler can use to decide what it wants to do:
ContainingList - (read-only) of type IEnumerable returns the list that contains the data item.
Item - (read-only) of type object returns the data item in question
FieldLayout - (get/set) Returns/sets the FieldLayout assocaiated with the item
IsAddRecord - (read-only) returns true if data item is associated with an 'add record'
Hope this helps.
JoeM