flex表格的使用

flex表格的使用

Flex中表格使用datagrid+columns两个组件构成,dagagrid中定义了表格的外观属性和数据源
Columns中定义了表格的列名还有对应的字段,方便从数据源取得数据

数据源的赋值一般有两种方法:
第一种:直接在datagrid中定义数据源
Var dataSource:ArrayCollection = new ArrayCollection(); //数据源的格式
<mx:DataGrid id = “grid” dataProvider="{dataSource}"> 通过这种直接绑定的形式获得数据源

第二种:外部赋值,通过id来确定数据源
Var dataSource:ArrayCollection = new ArrayCollection();
<ms:DataGrid id = “grid”>
grid.dataProvider = dataSource; //通过这种赋值的方式来获取数据源

表格的列
<mx:columns>
<mx:DataGriColumn headerText = “columnName” width = 88 dataField = “columnName”>
</mx:columns>
表格的列名是headerText,具体的值是由dataField从数据源中取得的

 

注:在<mx:DataGrid>中,还可以设置滚动条,双击事件,单击事件等,点击事件获得具体对象可以通过selectedItem这个对象获取。

相关文章:

  • 2022-12-23
  • 2021-08-15
  • 2021-11-16
  • 2022-12-23
  • 2022-12-23
  • 2022-03-02
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-02
  • 2022-12-23
  • 2021-12-05
  • 2021-09-10
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案