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

Nested Child-Collection example in dashboard. How to add nested child table programmatically?

Hi,

I am using the GridGroupingControl that works similar as the Nested Child-Collection example in the winform dashboard.

I couldn't find a way to programmatically add a child table after the data source is bound.

Here is my example modification from the "Nested Child-Collection example",

First I modify the BaseClassList to BindingList so that it supports update

public class BaseClassList : BindingList<BaseClass>, ITypedList

In the Form1 constructor, after 

            _gridGroupingControl1.DataSource = theList;

I added these to just test programmatically changing the list.

            Action mystuff = () =>
            {
                var list = new BaseClassList();
                for (int i = 0; i < 5; i++)
                    list.Add(new SecondClass(theList[0], i, "myItem" + i));
                theList[0].ChildTables.Add("XXXXChild_Of_List0", list);
            };

            Thread tt = new Thread(() => {
                Thread.Sleep(3000);
                _gridGroupingControl1.Invoke(mystuff);
            });
            tt.Start();


There is no effect after few seconds. 
I also tried unbind the data source and bind it again it still doesn't work.


1 Reply

AK Adhikesevan Kothandaraman Syncfusion Team May 25, 2016 02:36 PM UTC

Hi Paul, 

Thanks for using Syncfusion products. 

If you want to add the additional child table on runtime, please reset the Datasource of the GridGroupingControl and then set the updated source to the grid. Please refer to the following code snippet, 

Code Snippet: 
var list = new BaseClassList(); 
for (int i = 0; i < 5; i++) 
    list.Add(new SecondClass(theList[0], i, "myItem" + i)); 
theList[0].ChildTables.Add("NewChild", list); 
 
this.gridGroupingControl1.DataSource = null; 
//Set the updated source to the Grid 
this.gridGroupingControl1.DataSource = theList; 
 
this.gridGroupingControl1.Refresh(); 
 
 
Sample Link: 


Regards, 
Adhi 


Loader.
Up arrow icon