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

GridDropDownCellRenderer and DataRow

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

3 Replies

AD Administrator 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.


TH TheoC March 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


TH TheoC March 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

Loader.
Live Chat Icon For mobile
Up arrow icon