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
230
Hierarchical data and field layout issue
posted

Hi,guys,my data grid's datasource is hierarchical data, and I needs to define the FieldLayout in Xaml file,how can I define both the parent records and child record's fieldlayout?

Parents
  • 8576
    Offline posted
    Hi Susie -
     
    You would do this by creating a 2 FieldLayouts - one for the parent records and one for the child records, and adding them to the XamDataGrid's FieldLayouts collection.  Assuming the Fields you defined the FieldLayouts match the fields in your data source for both the parent and child tables, the XamDataGrid will use those FieldLayouts and properly display the hierarchical data. 
     
    BTW, one thing that makes it tricky to manually define FieldLayouts for parent and child tables with relationships, is that you need to be sure to include definitions for the IEnumerable Fields that a hierarchical data source automatically creates in the parent table based on the defined relationship between the tables, to represent the child rows.  It is not always easy to know the names of these Fields since the DataSource usually creates them on the fly. 
     
    However, if you don't try to do this manually and you let the XamDataGrid 'discover' the structure of the data source it will automatically do this work for you.  If you then wanted to exclude certain of the automatically generated Fields from the FieldLayout, you could listen to the XamDataGrid's FieldLayoutInitialized event and iterate through each Field in the FieldLayout and set the Visibility of the ones you want to hide to Visibility.Collapsed.
     
    Hope this helps.
     
    Joe
     
Reply Children