Flex DataGrid and Buttons in Rows

So you’re working in Flex, and you’ve got a DataGrid.  The grid’s showing some data you’ve bound it to, and you want to have a button in a row that, when you click it, does something to one of the properties of the row.

Easy.  In the click event for your button, the ‘data’ property is the current row.  Here’s a button that sets the lastDone property of the row to the current date:

<mx:DataGridColumn editable="false">
<mx:Button label="Done Today"
click="data.lastDone = new Date();"/>

This gives me a column with a button in it, whose click event sets the lastDone property of the current row to the current date.  No extra code anywhere else; that’s all there is to it.