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

Access to datasource row in gridGroupingControl1_QueryCellStyleInfo.

Hello. I am in gridGroupingControl1_QueryCellStyleInfo handler. How can I get datasource row, for which the cell belongs to ? Thank you.

3 Replies

AD Administrator Syncfusion Team May 14, 2004 12:41 AM

You can GridRecord from the e.TableCellIdentity.DisplayElement. From the record, you can get the underlying DataRowView (or what ever object fills the rows in your IList datasource).
if(e.TableCellIdentity.DisplayElement is GridRecordRow)
{
	GridRecordRow row = e.TableCellIdentity.DisplayElement as GridRecordRow;
	if(row != null)
	{
		GridRecord record = row.ParentGroup.Records[0] as GridRecord;
		if(record != null)
		{
			DataRowView drv = record.GetData() as DataRowView;
			Console.WriteLine(e.Style.Text + " " + drv["LastMarket"].ToString() + " " + e.TableCellIdentity.ColIndex.ToString());
		}
	}
}


AD Administrator Syncfusion Team May 14, 2004 01:06 AM

In this example always returned first record in datasource row.ParentGroup.Records[0]. How to get right source row index (for the specified cell)? Thank you.


AD Administrator Syncfusion Team May 14, 2004 02:00 AM

Try working directly with the row instead of its parent.
if(e.TableCellIdentity.ColIndex > 0 && e.TableCellIdentity.RowIndex > 0 &&
	e.TableCellIdentity.DisplayElement is GridRecordRow
	&& e.TableCellIdentity.Column != null) //make sure a column is being requested
{
	GridRecordRow row = e.TableCellIdentity.DisplayElement as GridRecordRow;
	if(row != null)
	{
		DataRowView drv = row.GetData() as DataRowView;
		if(drv != null)
		{
			string name = e.TableCellIdentity.Column.Name;
			Console.WriteLine(e.Style.Text + " " + drv[name].ToString());
		}
	}
}

Loader.
Live Chat Icon For mobile
Up arrow icon