ActionScript 2 DataGrid Cell Redraw

I’ve never really had much use for the Flash DataGrid until a recent project. One of the tasks involved updating a field of a certain row. I was doing it like:

this.datagrid_clinicians.dataProvider[clinician_index].total_presentations--;

Essentially, there is an array of objects. One of the object properties is called “total_presentations”. The above line tell a specific DataGrid row to decrement it’s total_presentations property by one. That works as expected except that the actual field doesn’t change visually until you roll over/off the updated row which looks rather bad. Calling invalidate or redraw on the DataGrid didn’t help. Turns out I’d simply overlooked a DataGrid method called editField. The above line can be rewritten:

this.datagrid_clinicians.editField(clinician_index, "total_presentations", this.datagrid_clinicians.dataProvider[clinician_index].total_presentations - 1);

A bit long winded compared to the first option but it seems to redraw the cell instantly. I just totally missed this method when reading the docs. Luckily I only had to change it in a few places, later on it would of been a lot more trouble.

Share Article

Comments: None so far...be the first!

Leave a reply

Please fill in the form fields and improve Skynet by completing the captcha!

Thank you! All comments are moderated so yours will appear shortly.

It takes a lot of effort not to be free

— Randall Becker, The Man in the High Castle