Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
165
Binding a FieldLayout to a XamComboEditor
posted

I created a fieldlayout in the backend and I am trying to display it in a XamDataGrid, but the fields I created won't display. As a matter of fact, nothing appears on the grid. What seems to be my problem?

Here is my xaml code:

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="">schemas.microsoft.com/.../presentation"
        xmlns:x="">schemas.microsoft.com/.../xaml"
        Title="MainWindow" Height="350" Width="525" xmlns:igWPF="">schemas.infragistics.com/.../wpf">
    <Grid>
        <Grid>
            <DockPanel LastChildFill="True" Margin="0,26,0,-26">
                <igWPF:XamDataGrid x:Name="Account_Info_XamDataGrid">
                </igWPF:XamDataGrid>
            </DockPanel>
        </Grid>
    </Grid>
</Window>

and the backend:

private void ShowAccountInfoGrid()
{        
    ComboBoxItemsProvider title_provider = new ComboBoxItemsProvider();
    ComboBoxItemsProvider code_provider = new ComboBoxItemsProvider();
    List<Acc_LinkDTO> Acc_lists = new List<Acc_LinkDTO>();

    Acc_lists = _Acc_LinkUIAdapter.getAllAcc_Links().ToList();
    accounts = _AccountUIAdapter.getALlGroup();

    Account_Info_XamDataGrid.FieldLayouts.Clear();
    foreach (var x in Acc_lists)
    {
        int i = 0;
        title_provider.Items.Add(new ComboBoxDataItem(i, x.Acc_LinkTitle));
        i++;
    }

    foreach (var x in accounts)
    {
        int i = 0;
        code_provider.Items.Add(new ComboBoxDataItem(i, x.Code2));
        name_provider.Items.Add(new ComboBoxDataItem(i, x.Name));
        i++;
    }

    //First column
    Field fld1 = new Field();
    fld1.Name = "Account Title";
    Style style1 = new Style(typeof(XamComboEditor));
    style1.Setters.Add(new Setter(XamComboEditor.ItemsProviderProperty, title_provider));
    fld1.Settings.EditorStyle = style1;
    fld1.Settings.EditorType = typeof(XamComboEditor);
    fieldLayout.Fields.Add(fld1);

    Account_Info_XamDataGrid.FieldLayouts.Add(fieldLayout);
}
  • 0
    Offline posted

    If you want to utilize your FieldLayout with an IEnumerable set to the DataSource of your grid, make sure that the Name attributes of the Field match up with a property on your underlying data item.

  • 34830
    Offline posted

    Hello Nour,

    I have been investigating into the behavior you are looking to achieve, and most of the code that you provided looks good in this case, but it appears to be missing a DataSource setting for the XamDataGrid. This is what will generate the records for the grid, and the Name properties of the Field need to match up to a property on your underlying data item in the IEnumerable set to the DataSource of the grid, otherwise your FieldLayout will not be used.

    You can read further about generation of FieldLayouts in the XamDataGrid by using this online documentation article. 

    Please let me know if you have any other questions or concerns on this matter.