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

Determining DataTable column name associated with cell in GDBG

What is the easiest way to determine the name of the underlying DataTable column of the current cell? The following works on grids where one record takes up a single row, but not when a single record spans two rows in the grid: int intCurrentCol = grid.CurrentCell.ColIndex; grid.GridBoundColumns[intCurrentCol].MappingName

4 Replies

AD Administrator Syncfusion Team April 7, 2005 10:37 PM UTC

Try this code.
string name;
int rowIndex = this.gridDataBoundGrid1.CurrentCell.RowIndex;
int colIndex = this.gridDataBoundGrid1.CurrentCell.ColIndex;
GridBoundRecordState rs = gridDataBoundGrid1.Binder.GetRecordStateAtRowIndex(rowIndex);
GridHierarchyLevel ghl = gridDataBoundGrid1.Binder.GetHierarchyLevel(rs.LevelIndex)  as GridHierarchyLevel;
int field = this.gridDataBoundGrid1.Binder.ColIndexToField(colIndex);

if(ghl.RowCountPerRecord == 1)
{
	name = ghl.GridBoundColumns[field].MappingName;
}
else
{
	field = ghl.RowFieldToField(rs.RowIndexInRecord, field);
	name = ghl.GridBoundColumns[field].MappingName;
}
Console.WriteLine(name);


LS Lori S. Pearsall April 7, 2005 10:51 PM UTC

Thanks Clay - works perfectly!


AM Ashes Mukherjee April 20, 2008 05:57 PM UTC

Have implemented a hierarchical griddataboundgrid. (attached sample)

The following is not working:

Have tried to hide columns that are in child tables (not at the top level and not in the relation), did not work.

Additionally, need to overwrite cell contents of columns that are in the parent/child relation. (Note: only need to overwrite on display, not modify underlying datasource)

Attempted to overwrite content by handling Model.QueryCellInfo, but this is causing relation and hierarchy layout to fail.

Appreciate prompt assistance as project is on critical path.

Thanks



GridDataBoundGridHierarchyApp.zip


AM Ashes Mukherjee April 21, 2008 06:59 PM UTC

Please ignore the previous question. We found the solution.


Loader.
Up arrow icon