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
close icon

GridTableModel Bug?

Hi together, I have a gridgroupingcontrol which is bound to a dataset object consisting of four tables. Now when I want to get the TableMode of a specific table I use the following code: GridTableModel model = gridGroupingControl1.GetTableModel("A"); Everything seems fine, but when I try to get the GroupingControl property like this: GridGroupingControl actCtrl = model.GroupingControl I get a null reference. But the DataSet is already bound to the grid. Any ideas? Cheers, Markus

4 Replies

AD Administrator Syncfusion Team August 23, 2005 09:16 AM UTC

Here is the code that defines this property in our library.
public GridGroupingControl GroupingControl
{
	get
	{
		Control c = this.ActiveGridView;
		while (c != null)
		{
			if (c is GridGroupingControl)
				return (GridGroupingControl) c;
			c = c.Parent;
		}

		return null;
	}
}
As you see, it is a dynamically set property that will return return null when there is no ActiveGridView associated with the GridTableModel. (In general, the only TableModel with such an active grid view is the parent one, this.grid.TableModel). So, if you need to look up the GroupingControl based on a child GridTableModel, you could use a Hashtable that you set up yourself. But you cannot rely on the tableModel.GroupingControl property.


AD Administrator Syncfusion Team August 23, 2005 09:17 AM UTC

Hi I think that you might not have created a new GirdGroupingControl using the following code. So add the code and then check. GridTableModel model = gridGroupingControl1.GetTableModel("A"); //Code to be added. GridGroupingControl actCtrl = new GridGroupingControl(); actCtrl = model.GroupingControl;


AD Administrator Syncfusion Team August 23, 2005 09:55 AM UTC

This has no influence - actCtrl is still a null reference. >Hi > > I think that you might not have created a new GirdGroupingControl using the following code. >So add the code and then check. > >GridTableModel model = gridGroupingControl1.GetTableModel("A"); > >//Code to be added. >GridGroupingControl actCtrl = new GridGroupingControl(); > > actCtrl = model.GroupingControl;


AD Administrator Syncfusion Team August 23, 2005 10:20 AM UTC

That is to be expected. As the only TableModel that has an active view is this.gridGroupingControl1.TableModel. Check this.gridGroupingControl1.TableModel.GroupingControl and I think you will see it is not null. But any tablemodel you get by calling GetTableModel passing any string other than this.gridGroupingControl1.TableModel.Table.TableDescriptor.Name will return null. So, if you want to access the GridGroupingControl from child table models, then you will have to handle this yourself, say using a hashtable as suggested above.

Loader.
Live Chat Icon For mobile
Up arrow icon