Hello,
I am working with a UltraWinGrid and UltraDataSource. The requirement is that anytime a value in the grid changes, the grid cell appearance (backcolor/forecolor) changes. What is the best way to do this using Infragistics? Is there a design pattern I could follow?
The solution I have is to remember values that have changed before update the UltraDataSource row, and then to use this data structure to set the appropriate appearance (dirty/clean) in the InitializeRow event of the UltraWinGrid. Then, call RefreshRow on the "changed" UltraWinGrid rows when the value is no longer considered dirty. This feels a bit hacky to me, but it works.
Another idea: Add a column or columns to the UltraDataSource storing the "dirty status" of the UltraWinGrid cells, and perform similar logic in the InitializeRow event. This solution avoided the "Refresh" iterations when trying to un-dirty a cell, but it bloats my UltraDataSource with extra columns.
Am I missing something?
Thanks, Steve
Hi Steve,
The grid doesn't really keep track of changed cells. The grid only deals with the local DataSource, anyway. So the only thing the grid tracks is changes made to the grid that have not yet been committed to the DataSource.
You probably want to track data that has changed in both the grid and the data source, but has not yet been committed to the back end (the database). For something like that, it's really the data source's responsibility to track it. The DataSet / DataTable classes in DotNet have method for keeping track of the state of rows and it works with the DataAdapter to update the back end.
Hi Brian,
Thank you for the response, I appreciate it. I don't think the DataChanged property is what I am looking for, as I am programmatically making changes to the DataSource and not the UltraWinGrid. So, in InitializeRow (when I need to color a cell as "changed" or "normal"), the DataChanged property is always false.
As I mentioned in the original post, I have the functionality working, and I am just wondering if there is a better way to do it.
What would be really neat is... if there was a way on the grid to specify a "changed" appearance for when a cell value changes, and then some sort of mechanism for expiring the "changed" appearance. It would be even neater to add some animation support into the grid to allow a "dirty" cell to fade back to the normal appearance.
Thanks! Steve
UltraGridRow and UltraGridCell both expose a DataChanged property, which basically returns whether there are any changes pending.