The Syncfusion native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
Hi,
I have a custom dropdown control that inherits from GridDropDownCellRenderer. The dropdown is used in gridgroupingcontrols and in a GridControl. I need to get the underlying current DataRow from the CurrentCell in the overriden OnInitialize(int rowIndex, int colIndex) method. Sorting and all other kinds of madness are possible so I can''t rely on the rowIndex or colIndex, just CurrentCell. Please help.
Thanks,
Theo C
ADAdministrator Syncfusion Team March 8, 2005 09:45 AM UTC
The CurrentCell is not always the cell that is passed to renderer.OnInitailize. In that event, you must get at the infromation using the passed in row and column.
In a groupinggrid, you can get the record through the TableControl using code like:
GridTableCellStyleInfo style = gridGroupingControl.TableControl.Model[row, col];
//get some record data
GridRecordRow grr = style.TableCellIdentity.Table.DisplayElements[row] as GridRecordRow;
DataRowView drv = grr.GetData() as DataRowView;
SInce a GridControl does not have a DataSource, I am not sure how any datarow is being mapped into the GridControl. If you are using a virtual grid and displaying data through the DataTable.DefaultView, then you can get the data through the DataView (or through the CurrencyManager). Maybe like this:
DataRowView drv = dataView1[row-1];
where dataView1 is the dataview you are using to provide the sorted data.
THTheoCMarch 8, 2005 12:38 PM UTC
Thank you for the response, this does not seem to work though. The grr.GetData() allways returns null. I modified the code (last line) to look like this:
GridStyleInfo gsi = this.Grid.Model [this.CurrentCell.RowIndex, this.CurrentCell.ColIndex];
GridTableCellStyleInfoIdentity gtsi = (GridTableCellStyleInfoIdentity) gsi.CellIdentity;
DataRow current_row = (DataRow)gtsi.DisplayElement.EngineTable.CurrentRecordManager.Data;
Which seems to work fine for the parent table, but not for the Nested tables. Why doesn''t it work.
Thank you for the assistance
Theo C
THTheoCMarch 8, 2005 01:14 PM UTC
Ok, so I its workin now. I got it to work by doing the following from within the Custom Dropdown OnInitialize method:
GridTableCellStyleInfo gsi = (GridTableCellStyleInfo) this.Grid.Model[rowIndex, colIndex];
GridTableCellStyleInfoIdentity gtsi = (GridTableCellStyleInfoIdentity) gsi.CellIdentity;
GridRecordRow grr = gtsi.Table.DisplayElements[rowIndex] as GridRecordRow;
DataRow current_row = (DataRow) grr.GetData();
Hope that helps anyone.
Thanks