Search code examples
apache-flexactionscriptairitemrenderer

Selecting a row a clicked button itemrenderer resides within?


Inside a datagrid, I essentially want to create a "download button" itemrenderer to the right of the name of a downloadable object, resulting in something like the following link: https://i.sstatic.net/HXUlB.png

The download function operates upon the currently selected row and is called when one of the download buttons is clicked. Therefore, I am wondering if anybody knows of a way to select the row the itemrenderer button is contained within as the active row when one of the download buttons is clicked.


Solution

  • I would use something like this

    var index:int = dg.itemRendererToIndex(ir);
    dg.selectedIndex = index;
    

    where dg is your DataGrid and ir is your itemRenderer

    hope this helps.

    f