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
1100
Are multiple root tables possible?
posted

When a XamDataGrid's root table is expanded, it may yield multiple child tables. Is there a way to show multiple root tables OR is there a way to have a hidden root table with multiple child tables that are presented to an end-user as root tables?

Thanks.

  • 1100
    Verified Answer
    posted

    Ok I figured this out. To simulate multiple roots with a DataSet, make a dummy root table with one field that is used as a key to any immediate child tables. Next, set the datasource to that dummy root table. In XAML, modify the FieldSettings of that field added to the dummy root table. The modifications should be like so:

    Lastly, in the XamDataGrid's InitializeRecord event, the root record has to be detected when it's initially displayed; after which, it has to be expanded and it's expansion indicator rendered invisible:

    <igDP:Field Name="ComponentType" Label="Component Type" Visibility="Hidden">

    <igDP:Field.Settings>

     

     

     

     

     

    <igDP:FieldSettings CellMinWidth="0" CellMaxWidth="0" CellWidth="0" CellMinHeight="0" CellMaxHeight="0" CellHeight="0" />

     

     

    </igDP:Field.Settings>

    </igDP:Field> 

     

    // Ensure the root record has an invisible expansion indicator and is automatically expanded.

     

     

     

     

     

    if (e.Record == e.Record.UltimateParentRecord)

    {

    e.Record.IsEnabled =

    false;

    // To prevent automation accidents.

    e.Record.ExpansionIndicatorVisibility =

    Visibility.Hidden;

    e.Record.IsExpanded =

    true;

    }

    That's it! Thanks.

  • 69686
    Verified Answer
    posted

    Hello,

    Regarding your first question, I believe this is not possible. You can do this, but by adding DataItems objects in the DataItems collection of the XamDataGrid, but is not available for DataTabled.

    However, it is possible to do this using a root DataTable, which has parent-child relations to two other DataTables and bind the root DataTable to the DataSource of the XamDataGrid.

    Hope this helps.