Flash builder: How to get selected Cell value in datagrid?

Go To StackoverFlow.com

2

I have a datagrid that is editable. I was wondering if it's possible to retreive the cell value after user edits the single cell.

My datagrid will trigger griditemEditorSessionSave event if users finish the editing, but I don't know how to get the new cell value.

//script
protected function dg_gridItemEditorSessionSaveHandler(event:GridItemEditorEvent):void
  {
     //I can only get the columnIndex but not the value
      Alert.show (event.columnIndex);

  } 

//mxml

<s:DataGrid id="dg" editable="true" x="5" y="3" width="734" height="153"
                  gridItemEditorSessionSave="dg_gridItemEditorSessionSaveHandler(event)"
>
....
.....

</Datagrid>

Any thoughts? Thanks a lot.

2012-04-05 00:03
by Rouge
I haven't had a chance to use Spark DataGrid yet. But when that event is dispatched, the item that was edited has been saved back to your dataProvider. You could use the rowIndex property of the event to get the index of the item in the dataProvider. And use the columnIndex to deduce which property of the item was edited. Another idea is to check event.target - not sure if that will be the renderer for the cell that was edited, or perhaps the dataGrid itself.. - Sunil D. 2012-04-05 00:38


0

Yes, this is possible..just recently i had this same problems.Im familiar thats theres not much As3 docs into this subject as such more or less on only innitializing the DataGrid and populating it, hence; Not grabbing the values its self.

On my Datagrid i found it was easier to save the whole dataGrid each time it was edited as i didnt find a way to do this for each individual cell.Just as a text file with comma's seperating the values

Using a loop function to go through each arrays length, Column / row, if you need complete source code for this project goto:

http://ffiles.com/flash_files/3559/index.html

2012-04-05 01:21
by joshua
Ads