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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GridRecordRow in a nested table

Thread ID:

Created:

Updated:

Platform:

Replies:

27931 Apr 20,2005 01:16 PM UTC Apr 29,2005 08:20 AM UTC WinForms 6
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On April 20, 2005 01:16 PM UTC

Hi, i would like to get a reference to a Gridrecord the user clicked. I got it working when I click a Cell in the parent table. Unfortunately it doesn''t when a cell in a nested table gets clicked. How would i change the following code so that i can get a reference to the corresponding child record: GridCurrentCell cc = e.TableControl.CurrentCell; GridTableCellStyleInfoIdentity tableCellInfo = e.TableControl.CurrentCell.Renderer.StyleInfo.CellIdentity as GridTableCellStyleInfoIdentity; GridTableCellStyleInfo style = e.TableControl.Model[cc.RowIndex, cc.ColIndex]; GridRecordRow r = style.TableCellIdentity.DisplayElement as GridRecordRow; string s = string.Format("val:{0} row:{1} col:{2}", r.ParentRecord.GetValue(style.TableCellIdentity.Column.MappingName), cc.RowIndex, cc.ColIndex); this.m_ContextMenu.MenuItems.Clear(); this.m_ContextMenu.MenuItems.Add(s); if (GetTableCellStyle(e.TableControl) == GridTableCellType.RecordFieldCell || GetTableCellStyle(e.TableControl) == GridTableCellType.AlternateRecordFieldCell) { GridColumnDescriptor column = GetColumnDescriptor(e.TableControl); if (Convert.ToInt16(r.ParentRecord.GetValue(Constants.DataBase.col_ETVTmanuell)) == 1) { this.m_ContextMenu.MenuItems.Add(ml.ml_string(195, "Reset Row"), new EventHandler(Context_ResetRow_Click)); if (column.Name == Constants.DataBase.col_ETVT_Custom) this.m_ContextMenu.MenuItems.Add(ml.ml_string(196, "Reset Single"), new EventHandler(Context_ResetSingle_Click)); } }

Administrator [Syncfusion]
Replied On April 20, 2005 02:02 PM UTC

This code works for me.
private void gridGroupingControl1_TableControlCellClick(object sender, GridTableControlCellClickEventArgs e)
{
	GridTableCellStyleInfo style = e.TableControl.Model[e.Inner.RowIndex, e.Inner.ColIndex];
	GridRecordRow r = style.TableCellIdentity.DisplayElement as GridRecordRow;
	string s = string.Format("val:{0} row:{1} col:{2}", r.ParentRecord.GetValue(style.TableCellIdentity.Column.MappingName), e.Inner.RowIndex, e.Inner.ColIndex);
	Console.WriteLine(s);
}

Administrator [Syncfusion]
Replied On April 21, 2005 10:14 AM UTC

Please see the attached sample. When I right-click a nested cell there i would like to display the content of Col0 of the same row in the popup. But something goes wrong with the indexes and i''m not sure wether this is the way to go. Thanks for your help GGC_BookMark_9669.zip

Administrator [Syncfusion]
Replied On April 21, 2005 10:55 AM UTC

Try using this code in TableControlCellClick. It seems to work in your sample for me.
private void gridGroupingControl1_TableControlCellClick(object sender, GridTableControlCellClickEventArgs e)
{
	if( e.Inner.MouseEventArgs.Button == MouseButtons.Right )
	{
		GridTableCellStyleInfo style = e.TableControl.Model[e.Inner.RowIndex, e.Inner.ColIndex];
		GridRecordRow r = style.TableCellIdentity.DisplayElement as GridRecordRow;
		if(r.ParentRecord != null)
		{
			barItem1.Text = "val:" + r.ParentRecord.GetValue(style.TableCellIdentity.Column.MappingName).ToString() + "   col:" + e.Inner.ColIndex.ToString() + ", row:" + e.Inner.RowIndex.ToString();

			popupMenu1.Show(gridGroupingControl1, new Point(e.Inner.MouseEventArgs.X, e.Inner.MouseEventArgs.Y));
		}
	}
}
 

Administrator [Syncfusion]
Replied On April 27, 2005 04:15 PM UTC

I need to do it outside of an event. I would like to set a cell of the selected child row to a specific value. If you refer to the sample i sent you i would need to set that value inside of the menu_click function. Thanks

Administrator [Syncfusion]
Replied On April 28, 2005 09:46 PM UTC

Hi Oliver, here is a modified click function that toggles the value of the current record for both nested and parent table: private void button3_Click(object sender, System.EventArgs e) { Element el = this.gridGroupingControl1.Table.CurrentElement; while (el is NestedTable) el = ((NestedTable) el).ChildTable.ParentTable.CurrentElement; if(el != null) { Record r = el as Record; if (r == null) r = el.ParentRecord; if (r != null) { bool b = r.GetValue("boolCol") == DBNull.Value ? true : !(bool)r.GetValue("boolCol"); if(!r.IsEditing) r.BeginEdit(); r.SetValue("boolCol", b); r.EndEdit(); } } } Stefan >I need to do it outside of an event. I would like to set a cell of the selected child row to a specific value. If you refer to the sample i sent you i would need to set that value inside of the menu_click function. > >Thanks

Administrator [Syncfusion]
Replied On April 29, 2005 08:20 AM UTC

perfect - works ! thank you

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;