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

Adding child group at runtime

Hi,

I have bind the collection to the grid grouping control with 3 grouping columns.
Now I have to add a one more group below the third group having all columns same as binded datasource but data for the group4 is coming from different datasource i.e second collection.
Can this possible in grid grouping control.

In short i need to add child table same like we add in relation of master detail....but i dont want it as a seperate child grid....i want that should be the part of same grid as columns are same but my data source is different

Please help urgently

1 Reply

AD Administrator Syncfusion Team February 7, 2007 06:30 PM UTC

Hi,

You can add UnBoundFieldDescriptor for the columns that you want to dynamically change from either table to the grid. Then make one table the grid’s datasource and use .QueryValue event to dynamically provide the values from the other table. If you want to handle editing, you would also have to handle SaveValue event.

this.gridGroupingControl1.TableDescriptor.UnboundFields.Add("TableColumnTwo0");
this.gridGroupingControl1.TableDescriptor.UnboundFields.Add("TableColumnTwo1");
this.gridGroupingControl1.TableDescriptor.UnboundFields.Add("TableColumnTwo2");

//Used for saving/Editing the data in the filed.
private void gridGroupingControl1_SaveValue(object sender, FieldValueEventArgs e)
{
GridTable table = this.gridGroupingControl1.GetTable(e.TableDescriptor.Name);
int iRecordIndex = table.UnsortedRecords.IndexOf(e.Record);
string sColumnName = e.Field.Name;
table2.Rows[iRecordIndex][sColumnName] = e.Value;
}

//For display purpose....
private void gridGroupingControl1_QueryValue(object sender, FieldValueEventArgs e)
{
GridTable table = this.gridGroupingControl1.GetTable(e.TableDescriptor.Name);
int iRecordIndex = table.UnsortedRecords.IndexOf(e.Record);
string sColumnName = e.Field.Name;
e.Value = table2.Rows[iRecordIndex][sColumnName];
}

Please refer the sample for implementation.
CombineTables.zip

Best Regards,
Haneef

Notes :

Table1 => ID,Name,Rate
Table2 =>TableColumnTwo0,TableColumnTwo1,TableColumnTwo2

Loader.
Live Chat Icon For mobile
Up arrow icon