Flex 中的 DataGrid 自动刷新(转)


   当修改 DataGrid 实例的数据, 即修改数据源(dataProvider) 的内容时,要实现 DataGrid 的自动刷新,有两步。 1.将数据源设置为绑定。比如 数据源为 dataArray,要在声明时在上面加 [Bindable] 标签 [Bindable] var dataArray:Array; 有关数据绑定可以看看我的另外一篇文章http://hi.baidu.com/think122/blog/item/54970bfa2ae d732b4e4aea16.html 2.设置为绑定以后,当你修改数据时,DataGrid 实例不会显示新的数据,除非你鼠标点一下 DataGrid ,才会显示。 必须再手动进行刷新。DataGrid 有两个刷新函数,一个是下面的 invalidateList() ,这个函数用来刷新 DataGrid 的每一行,还有一个函数是 validateNow(),这个是在 DataGrid 的属性(大小,位置等)改变时,进行手动刷新的。我们要刷新纪录,就要用 invalidateList() 。所以在修改了数据后加上下面一行( dataGridInstance 是你的 DataGrid 实例) dataGridInstance.invalidateList(); 

猜你喜欢

转载自exo99exo.iteye.com/blog/1573099