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

There is no original data to access.

Hi all, I''m trying to provide "auto-coloring" in the grouping grid; i.e. when the contents of a numeric cell changes in value, for the cell background to change color for a short while, and then revert back to its default color. After getting some suggestions on this forum, I''m hooking the PrepareViewStyleInfo event in order to determine when a cell has changed in value. (Code is below.) I''m getting the exception "no original data to access" when this code runs, though. I see that this exception was also reported on these forums under a different scenario. It''s also a fairly significant defect in ADO.NET as far as I can tell by looking at google. So, my question is: a) is there any other easier way of providing auto-color function? b) RELATED: is there a way of going from cell RowIndex and ColIndex values to the underlying DataTable ColIndex and RowIndex values? I.e. a lot of the cell-related grid event handlers provide e.Inner.RowIndex/ColIndex. It would solve all my grid problems if I could somehow map these coords back to coords into the underlying DataTable. If the answer to b) is yes, then I can just store the row,col indexes of the underlying DataTable as I change the values, and map these during rendering to cell col/row indexes, and act acordingly. Many thanks, DM. private void RiptideGrid_TableControlPrepareViewStyleInfo(object sender, GridTableControlPrepareViewStyleInfoEventArgs e) { GridTableCellStyleInfo style = e.TableControl.Model[e.Inner.RowIndex, e.Inner.ColIndex]; if((style.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell || style.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell) && style.TableCellIdentity.DisplayElement != null) { if( style.TableCellIdentity.Column.Name == "Rate" ) { DataRowView drv = style.TableCellIdentity.DisplayElement.GetData() as DataRowView; if( drv == null ) return; object o = drv.Row[ style.TableCellIdentity.Column.Name, DataRowVersion.Original ]; if( !o.Equals(style.CellValue)) { Console.WriteLine("******" + drv[style.TableCellIdentity.Column.Name]); e.Inner.Style.BackColor = Color.Red; } } } }

2 Replies

AD Administrator Syncfusion Team December 10, 2004 08:25 AM UTC

a) If you want to format whole rows, then you can also use ConditionalFormats. But if you need to do a specific cell, then an event like PrepareViewStyleInfo or QueryCellStyleInfo is required. b) You can use the DisplayElement to get at the row in your datasource.
Record r = e.TableCellIdentity.DisplayElement as Record;
if(r != null)
{
	//get the DatarowView
	DataRowView drv = r.GetData() as DataRowView;
	//or get a single value
	object val = r.GetValue("Col1");
}


DM Dominic Morris December 10, 2004 09:42 AM UTC

Fantastic, thanks Clay. >a) If you want to format whole rows, then you can also use ConditionalFormats. But if you need to do a specific cell, then an event like PrepareViewStyleInfo or QueryCellStyleInfo is required. > >b) You can use the DisplayElement to get at the row in your datasource. >
>Record r = e.TableCellIdentity.DisplayElement as Record;
>if(r != null)
>{
>	//get the DatarowView
>	DataRowView drv = r.GetData() as DataRowView;
>	//or get a single value
>	object val = r.GetValue("Col1");
>}
>

Loader.
Live Chat Icon For mobile
Up arrow icon