We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to bind to a simple class with properties of List<T> for the child relations

I'm sorry if I'm missing a tutorial. I'm evaluating the GridGroupingControl. I have a class with public properties that I'm setting the DataSource of the grid to a List<T> for that class type. It works but now I'm trying create a relation that would expand a row and show another grid of a different class. The children of a row are a public property of List<T> for the childtype class. It is having a runtime error of   Message=Possible incorrect RelationDescriptor.ChildTableName for Relation relCauses.
Engine.SourceListSet[Causes] returned null.
Did you forget to call Engine.SourceListSet.Add(new SourceListSetEntry(Causes, list)
or did you specify a wrong ChildTableName?

Any advice or a simple demo of Parent/Children/Grandchildren using simple .NET bare bones classes with properties of List<T> for the children?

1 Reply

AR Arulpriya Ramalingam Syncfusion Team May 23, 2017 09:57 AM UTC

Hi David, 

Thanks for your interest in Syncfusion products. 

Query 
Response 
Did you forget to call Engine.SourceListSet.Add(new SourceListSetEntry(Causes, list) 
or did you specify a wrong ChildTableName? 
We have created a simple sample as per your requirement. The relational child table can be added to a parent table in GridGroupingControl by adding the childTable to Engine.SourceListSet. The childTable name should be registered with Engine.SourceListSet, so that the RelationDescriptor can get the child table name. Please make use of below code and samples, 
 
//Assigning Data source to Grid 
gridGroupingControl1.DataSource = parentTable; 
 
//Registering the child table with SourceListSet 
gridGroupingControl1.Engine.SourceListSet.Add("ChildTable",childTable); 
 
//Adding Foreignkey reference to grid 
GridRelationDescriptor relation = new GridRelationDescriptor(); 
relation.RelationKind = RelationKind.RelatedMasterDetails; 
relation.ChildTableName = "ChildTable"; 
relation.RelationKeys.Add("CategoryID", "CategoryID"); 
relation.ChildTableDescriptor.AllowEdit = true; 
gridGroupingControl1.TableDescriptor.Relations.Add(relation); 
 
Already we have provided the information in our user guide document. Please refer to the below link, 

 
Any advice or a simple demo of Parent/Children/Grandchildren using simple .NET bare bones classes with properties of List<T> for the children? 
We have provided the dash board samples with parent/child/grandchild table relations. Please refer the below samples, 
 
Dash Board sample link:  
<InstallLocation> \Syncfusion\EssentialStudio\<Product Version>\Windows\Grid.Grouping.Windows\Samples\Data Sources\Nested Child-Collection Demo\ 

<InstallLocation>\Syncfusion\EssentialStudio\<Product version>\Windows\Grid.Grouping.Windows\Samples\Relation And Hierarchy\Related Master Details Demo 


Regards, 
Arulpriya 


Loader.
Live Chat Icon For mobile
Up arrow icon