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
UltraGridRow and UltraGridCell both expose a DataChanged property, which basically returns whether there are any changes pending.
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
Thank you I looked all over for a flag and never saw that one.
Hi,
I think you need to set the AddRowModifiedByUser flag on the rows collection. This will tell the grid to treat the TemplateAddRow as though the user edited it.
I have a similar problem only I want to tell the grid that the row/cell is dirty.
When a cell is being added I have a cell button style on a column. When it is clicked some data is selected and I populate the proper cells with data. When the user presses enter the add row just sits there as if the data is not dirty. I have to tab to a cell whose data I did not set and modify it in order to get the row added.
What is the best way to populate a new row with data and still have the grid add it when the return key is hit if no other cells in the row are modified.
AddRow is a fixed row at the bottom
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.