How to access a cell Value in a Flex datagrid ?

29 01 2010

Unfortunately currently there is no easy way to get a cell value for a datagrid.There is already an enhancement request logged for this http://bugs.adobe.com/jira/browse/FLEXENT-826 If this fix is important to you please vote on this.

As of now to access a cell value this is what you will need to do

  1. Use selectIndex to choose the particular row
  2. Use GetROProperty(“selecteditem”) to get the entire contents of that row
  3. Using the split function you can then split the row contents to the contents of each cell using | as the delimiter

 Please find the sample code below

 Browser(“Browser”).FlexApplication(“dg”).FlexPanel(“DataGrid Control Example”).FlexDataGrid(“dg1”).SelectIndex 0

RowContents  =Browser(“Browser”).FlexApplication(“dg”).FlexPanel(“DataGrid Control Example”).FlexDataGrid(“dg1”).GetROProperty(“selecteditem”)

CellContents =Split(RowContents,”|”,-1)

msgbox CellContents(0)

msgbox CellContents(1)

msgbox CellContents(2)

Hope this helps!

Advertisements