Updating items directly in the DataProvider

This is one of those problems on which you could spend hours to find a solution. When having a DataGrid in Actionscript 3 and have a DataProvider behind it holding all data, updating the DataGrid can be quite a struggle. If you update the items in the DataProvider, they don’t show in the DataGrid, even though a simple trace learns that the items in the DataProvider are, in fact, updated. I’m not sure if this is a bug in Actionscript 3 or if Adobe intended it this way, but it can be quite a pain in the ass. Luckily, there is a simple work-around. So simple in fact, you might not even think of it.

To get the DataGrid to show the update, this is the simplest fix. All you have to do is add these two lines after your update code:

// Replace "yourDataGrid" with your DataGrid variable
yourDataGrid.enabled = false;
yourDataGrid.enabled = true;

And, as if by magic, the update appears. This makes life so much easier, just try it!

Leave a reply