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

GridGroupingControl: Changing column value.

Hello. Since I cannot bind datasource such way: http://www.syncfusion.com/Support/forums/message.aspx?MessageID=13836 I should set parent_ID column of newly created row manually. Please tell me how can done it. The best solution for me is to set cell value when the editing of new row begins. May be there is necessary event "NewRowCreated" ?

4 Replies

AD Administrator Syncfusion Team May 13, 2004 03:50 AM

You can also bind it with: DataSource = dataset1; DataMember = table1; And this will pick up the relation on table1, and auto populate the releated columns when you start editing a AddNew row in a child. Here is a little sample. nulls_1313.zip


AD Administrator Syncfusion Team May 13, 2004 04:35 AM

But in my situation I should show child table, not parent: this.gridGroupingControl1.DataSource = ds; this.gridGroupingControl1.DataMember = childTable.TableName; And parentID will not be assigned automatically. :(


AD Administrator Syncfusion Team May 13, 2004 08:12 AM

You can try handling the TableControlCurrentCellStartEditing event, and if it is teh AddNewRow, then set the value at this point.
private void gridGroupingControl1_TableControlCurrentCellStartEditing(object sender, GridTableControlCancelEventArgs e)
{
	Element el = this.gridGroupingControl1.TableControl.Table.CurrentElement;
	if(el != null && el is GridAddNewRecord)
	{
		this.gridGroupingControl1.Table.AddNew();
		Record r = el as Record;
		int col = this.gridGroupingControl1.TableControl.CurrentCell.ColIndex;
		int field = this.gridGroupingControl1.TableDescriptor.ColIndexToField(col);
		int someParentID = 1;
		r.SetValue("ParentID", someParentID);
	}
}


AD Administrator Syncfusion Team May 13, 2004 08:13 AM

You do not need the col and field lines in the above snippet.

Loader.
Live Chat Icon For mobile
Up arrow icon