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
100
Self referencing hierarchical data grid
posted

Good day.

I cannot create a hierarchical grid that uses only one datatable. It almost works but there is a problem: all the rows in the table are shown as a root element.

 Is there any way to filter out all the rows that have a parent row?

Example:
|ROOT
|-CAT_1
|--SUB_1_1
|--SUB_1_2
|---SUB_1_2_1
|---SUB_1_2_2
|--SUB_1_3
|-CAT_2
|--SUB_2_1
|---SUB_2_1_1

Data:
ID,PARENT_ID,CATEGORY
1,0,"ROOT"
2,1,"CAT_1"
3,1,"CAT_2"
4,2,"SUB_1_1"
5,2,"SUB_1_2"
6,2,"SUB_1_3"
7,5,"SUB_1_2_1"
8,5,"SUB_1_2_2"
9,3,"SUB_2_1"
10,9,"SUB_2_1_1"

Any ideas on how to do that? 

Thank you.

Parents
  • 8576
    Offline posted
    Hi -
     
    The XamDataGrid does not support the automatic discovery of relationships in the data it is bound to.  The XamDataGrid does what most (if not all) hierarchical grids do and that is it relies on the data source to structure the data based on the relationships (if any) that have been defined for the data. 
     
    Based on a data source with defined relationships (in this case a relationship between the ID and PARENT_ID fields), the structure that you have shown in your post would typically be exposed by the data source from the 'top down', rather than 'from the bottom up', with each record having backward references to its parent via the PARENT_ID field.  Each record would have a property of type IEnumerable that represents the collection of child records that have that record as its parent.
     
    Note that the XamDataGrid does support the ability to have a single FieldLayout that supports parent and child records that have the same structure. 
     
    Joe
     
Reply Children
No Data