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

CurrencyManager for nested tables in GGC

I have a GridGroupingControl bound to a DataSet with two tables and a relationship (say Customers and Orders). The GGC displays this in a hierarchy with a nested table. I''m trying to map from the current cell in the grid to a row in the DataSet. I can use the CurrencyManager to get a DataView for the parent table, but how do I get a DataView for rows in a nested table? Is there some context in the nested table that tells me what data member it is in the BindingContext? CurrencyManager cm = this.Grid.BindingContext[grid.DataSource, grid.DataMember] as CurrencyManager; DataView dv = cm.List as DataView; Doug

3 Replies

AD Administrator Syncfusion Team July 14, 2005 10:03 PM UTC

If all you need is the DataRowView associated with the currentcell in a GridGroupingControl, you can use:
Element el = this.gridGroupingControl1.Table.GetInnerMostCurrentElement();
if(el is GridRecord)
{
	DataRowView drv = el.GetData() as DataRowView;
}
You can also get a list of the records through GetInnerMostCurrentElement.
private void button1_Click(object sender, System.EventArgs e)
{
	Element el = this.gridGroupingControl1.Table.GetInnerMostCurrentElement();
	if(el is GridRecord)
	{
		DataRowView drv = el.GetData() as DataRowView;
		Console.WriteLine(drv[0]);
		GridChildTable gct = el.ParentChildTable as GridChildTable;
		Console.WriteLine(gct.ParentTable.FilteredChildTableOrTopLevelGroup.FilteredRecords.Count);
		Console.WriteLine(gct.ParentTable.FilteredChildTableOrTopLevelGroup.FilteredRecords[0]);
	}
}
Here is a little sample. http://www.syncfusion.com/Support/user/uploads/GGC_CM_9f5e57b5.zip


DO Doug July 14, 2005 11:32 PM UTC

Great! and I discovered a few more things about the different DisplayElements. Thank-you, Doug


AD Administrator Syncfusion Team July 14, 2005 11:33 PM UTC

In addition to get the child table from the CurrencyManager works like this: Assume you have a parent table called "Parent" and a child table called "Child" In the dataset, if you do: dataSet.AddRelation("ParentToChild", parentKey, childKey); You now have two ways to access the child table: You can get: CurrencyManager cm = this.grid.BindingContext[dataSet, "Child"] This will return the entire "Child" table. You can also do: CurrencyManager cm = this.grid.BindingContext[dataSet, "Parent.ParentToChild"] This second currency manager will show the subset of records that are related to the record pointed to by the Position property of the CurrencyManager on the parent table. That is, if you do: CurrencyManager parentCM = this.grid.BindingContext[dataSet, "Parent"] parentCM.Position = 0; then the records in cm will be the child records related to the first record in Parent. I''ve actually written two parts of a series of articles I''m writing on the CurrencyManager that explains this and a lot more on my web site here: http://www.petedavis.net/MySite/DynPageView.aspx?pageid=19 and http://www.petedavis.net/MySite/DynPageView.aspx?pageid=22 Good luck. Pete Davis

Loader.
Up arrow icon