I have an UltraGrid where some columns have an EditorWithCombo. The value lists are fetched from an API, and may change in the meantime. So, after refreshing the list itself, I also refresh the columns' value lists. This takes place by first emptying it (this becomes important later*), then filling it with new values.
Now, the following problem occurs:
Expected result: row 2's cell value shouldn't change.
Actual result: row 2's cell value reverts to null, unless the user hits the escape key.
I imagine this is a race condition: I'm still refreshing the value list, DataValueToText (maybe?) gets called on row 2, but the value list temporarily doesn't contain the value.
*) If I disable the code that clears ValueListItems, they issue does not appear to occur.
So, given all that, what I'd like to do is temporarily mark the value list as busy. However, it doesn't have a pair of BeginUpdate()/EndUpdate() methods, for example. I've also tried setting _Column.CellActivation = Activation.NoEdit as I'm refreshing, but this doesn't seem to work as of 22.1.20221.66: it appears that, while the cell isn't user-editable, the underlying data source is still modified.
Some more details:
OnBeforeRowUpdate doesn't yet get called. So the change to row 2 doesn't get committed until I hit enter. However, to the user, it looks like the value is empty.
Hello and thank you for contacting Infragistics.
Please elaborate your requirements in the way you are modifying the combo while the end user is in edit mode. I can't think of any reason where you would want to replace the datasource of a control especially while the user is in edit mode. Based on my understanding the issues would resolve itself if the the API you call that updates the value list items is only called while the cells are not in edit mode.
Here is a common scenario where you would want to have dependent dropdowns, but never replacing the value lists.
https://www.infragistics.com/community/product_platforms/winforms/b/winforms-blog/posts/creating-a-dropdown-list-in-a-grid-cell-whose-list-values-are-dependent-on-another-cell
Note, that we recommend filtering the list rather than updating the list. Let me know if you have any questions.
Hello Michael,
from your linked article, the "grid.EventManager.SetEnabled(GridEventIds.AfterCellUpdate, false);" line sounds interesting. It might help me here.
Indeed, dependent drop-downs do also (indirectly) play a role here. I'm going to use an example where we also have dependent drop-downs:
Consider a database design with the tables TimeTrackingEntries, Projects, and Subprojects, and a grid that lists time tracking entries. In this grid, I have columns such as duration, comment, etc. Project and Subproject, both of which are drop-downs that use the code in question. After selecting a project, the subproject gets reset, since it may not exist in the new project. This is similar to with your article's "If the user changes the “State” for a particular row, the “City” field would no longer be valid, since it still contains a city from a different state." section.
But, states and cities don't change much. Projects and subprojects can change all the time. What if someone else who's connected to the database has added more projects? My code tries to take care of that, by refreshing those drop-downs in the meantime based on database queries. The key flaw in my approach, perhaps, is that the refresh first clears the value list. If I instead compared to the new data from the backend, I would presumably avoid the issue (and slightly improve performance as well), but I was hoping for a simpler approach where I can suspend editing.