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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

There is no original data to access.

Thread ID:

Created:

Updated:

Platform:

Replies:

22305 Dec 9,2004 08:55 AM UTC Dec 10,2004 09:42 AM UTC WinForms 2
loading
Tags: Grouping
Dominic Morris
Asked On December 9, 2004 08:55 AM UTC

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; } } } }

Administrator [Syncfusion]
Replied On 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");
}

Dominic Morris
Replied On 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");
>}
>

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;