如何获取单个数据网格单元格值?
How to get individual datagrid cell values?
我正在尝试从数据网格中获取单元格值。假设数据网格有 4 列和 3 行,我该如何获取第 1 列第 1 行的单元格值?
我试过使用:
var column1row1: String = datagrid2.getItemAt (column1row1).Support_Type;
它给出了第 1 列的值,我不知道如何从这里开始?
使用 getItemAt()
只会在使用的索引处为您提供行(作为 Object
)(索引 1
将 select 第二行),然后要获取数据,您可以 select 列名,如下所示:
// supposed that the 2nd column (with index 1) is called 'email'
// and we are looking for the value of the cell[1, 1] (2nd row, 2nd col)
trace(data_grid.getItemAt(1).email);
// gives for example : email@example.com
您也可以使用 DataGrid.getCellRendererAt()
which will return an CellRenderer
object then you can use its listData
属性 来获得所需的值:
trace(data_grid.getCellRendererAt(1, 1).listData.label);
// gives for example : email@example.com
希望能帮到你。
我正在尝试从数据网格中获取单元格值。假设数据网格有 4 列和 3 行,我该如何获取第 1 列第 1 行的单元格值?
我试过使用:
var column1row1: String = datagrid2.getItemAt (column1row1).Support_Type;
它给出了第 1 列的值,我不知道如何从这里开始?
使用 getItemAt()
只会在使用的索引处为您提供行(作为 Object
)(索引 1
将 select 第二行),然后要获取数据,您可以 select 列名,如下所示:
// supposed that the 2nd column (with index 1) is called 'email'
// and we are looking for the value of the cell[1, 1] (2nd row, 2nd col)
trace(data_grid.getItemAt(1).email);
// gives for example : email@example.com
您也可以使用 DataGrid.getCellRendererAt()
which will return an CellRenderer
object then you can use its listData
属性 来获得所需的值:
trace(data_grid.getCellRendererAt(1, 1).listData.label);
// gives for example : email@example.com
希望能帮到你。