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
360
XAM Data Grid Datasource with Child Collections and AutoGenerateFields="False"
posted

Hi Team,

I am using XamDataGrid and the data source of the grid has a property that is a collection. By default when we bind this source, all the properties are displayed as grid columns and the child collection of each row is displayed with a expand button "+" in the left side, since by default the properties IsNestedDataDisplayEnabled="True" and AutoGenerateFields="True".

I have a requirement where I need to display only a few columns and each row with the child collection should still be displayed with the expand button "+" on the left side. I have set the properties to IsNestedDataDisplayEnabled="True" and AutoGenerateFields="False". By doing this the expand button "+" is shown but child grid is not displayed.

I have attached a sample with minimum data to demonstrate the same. Please let me know if there is a way we can achieve the above requirement but AutoGenerateFields="False" and not modifying the underlying entities.

Thanks,

Srikanth V.

XamDataTreeChildNodes.zip
Parents
No Data
Reply
  • 34830
    Offline posted

    Hello Srikanth,

    I have taken a look at the sample project you have attached, and currently, the reason that you are not seeing your child fields is because there are no child fields defined in your XAML.

    By setting the XamDataGrid.FieldLayoutSettings.AutoGenerateFields property to "False," this will mean that all fields in your XamDataGrid need to be manually generated, including the child ones. In the case of your XAML, you have a Field named Departments that points at a child collection on your data item, and this is required, but what is currently missing is a FieldLayout for that child collection.

    I would recommend that you add a secondary FieldLayout to your XamDataGrid.FieldLayouts collection, and set that FieldLayout's ParentFieldName property to "Departments." This will designate that FieldLayout as a child layout to your Departments field, and will allow you to add fields related to your child data item. The FieldLayout in the case of your sample project could look like the following:

    <igDP:FieldLayout ParentFieldName="Departments">
      <igDP:Field Name="DepId"/>
      <igDP:Field Name="DepName"/>
    </igDP:FieldLayout>

    I have attached a modified version of the sample project you sent to demonstrate the above.

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

    Sincerely,
    Andrew
    Associate Developer

    XamDataTreeChildNodes.zip
Children