Question

I have a very simple DataGrid with 2 columns, some thing like this:

<mx:DataGrid id="grid" >
    <mx:columns>
        <mx:DataGridColumn dataField="name" headerText="Name"/>
        <mx:DataGridColumn dataField="date" headerText="Date"/>
    </mx:columns>
</mx:DataGrid>

What Im trying to do is to activate the edition of the selected row when the user clicks a button. So far I've been unable to find any example of how to do this. I already tried 6 or 7 different approaches but non works. Does any one has a clue how to do this?

How do you get the selected row (NOT selectedItem) of a DataGrid and how can you:

  • Change the ItemRenderEditor or ItemRenderer on the fly of just that row.
  • Or enable the edition of that specific row without clicking it.

This are the questions that I've been unable to answer

Help will be greatly appreciated.

Was it helpful?

Solution

You can get the selected row with the grid.selectedIndex property. One thought to you problem:

  • Add an "editable" property to you items in the datagrid which is false by default
  • When clicking on the button, set grid.selectedItem.editable = true;
  • Change the grid's item renderer to a new one, which displays TextInput fields if an item is editable or just plain Label if it's not

You can change the item renderer at runtime like this:

grid.itemRenderer = new ClassFactory(com.myapp.renderers.MyGridItemRenderer);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top