Grouping Grid Child Elements, SourceListSet and Hierarchical DataSource

Hello,

I am binding hierarchical data sources (custom objects as well as DataSets with relationships) to a class inherited from the GridGroupingControl. I am having no problem in binding the source to the control, but I cannot determine how to get a reference to the different table controls and models that are now contained in the grid.

For example, I can use

base.TableControl

or

base.TableControl.Model

to get a reference to the top level parent elements. I have yet to find a method to retrieve the control and model references for the child elements. The only methods that are close to what I need are

base.GetTableControl()

or

base.GetTableModel()

These methods work well enough for direct access to a single child element (when the name is known) but I would like to be able to iterate all child elements and execute methods against the collection (adding handlers, etc.). I stumbled across the SourceListSet property, but I can''t determine when the information in the SourceListSet actually becomes available.

I''m trying to perform some custom routines immediately following the setting of a DataSource, so I''ve created the following property:

public new object DataSource
{
get
{
return base.DataSource;
}
set
{
base.DataSource = value;
// do something special
}
}

However, the SourceListSet isn''t populated immediately after setting the DataSource.

Any thoughts or ideas about how to loop through all elements, parent and children, in a dynamic fashion?

2 Replies

AD Administrator Syncfusion Team August 28, 2006 10:28 AM UTC

Hi John,

To iterate through all the nested/related table you can use the below code snippet.

Console.WriteLine( "Related Tables for " + this.gridGroupingControl1.Table.TableDescriptor.Name );
IterateRelatedTable( this.gridGroupingControl1.Table );

void IterateRelatedTable(Table table)
{
foreach(Table tb in table.RelatedTables)
{
Console.WriteLine( tb.TableDescriptor.Name );
if(tb.RelatedTables.Count > 0)
{
Console.WriteLine( "Related Tables for " + tb.TableDescriptor.Name );
IterateRelatedTable(tb);
}
}
}

Also refer to the Knowledge Base(KB) article link below, that helps in iterating through all the elements.

http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=360

Thanks,
Rajagopal



AD Administrator Syncfusion Team August 28, 2006 11:57 AM UTC

Hi Rajagopal,

That''s exactly what I was looking for. Thanks for your help!

>Hi John,

To iterate through all the nested/related table you can use the below code snippet.

Console.WriteLine( "Related Tables for " + this.gridGroupingControl1.Table.TableDescriptor.Name );
IterateRelatedTable( this.gridGroupingControl1.Table );

void IterateRelatedTable(Table table)
{
foreach(Table tb in table.RelatedTables)
{
Console.WriteLine( tb.TableDescriptor.Name );
if(tb.RelatedTables.Count > 0)
{
Console.WriteLine( "Related Tables for " + tb.TableDescriptor.Name );
IterateRelatedTable(tb);
}
}
}

Also refer to the Knowledge Base(KB) article link below, that helps in iterating through all the elements.

http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=360

Thanks,
Rajagopal


Loader.
Up arrow icon