开发者

Alternative to data binding

开发者 https://www.devze.com 2023-01-20 11:49 出处:网络
As an alternative to binding an array collection to a data grid\'s data provider, could I assign the array collection as the d开发者_开发技巧ata provider to the data grid on it\'s creation and everyti

As an alternative to binding an array collection to a data grid's data provider, could I assign the array collection as the d开发者_开发技巧ata provider to the data grid on it's creation and everytime the array collection is updated execute invalidateProperties(); invalidateList(); to re-render the data grid?

Does my described approach make sense?


Does my described approach make sense?

Sort of. If you have an arrayCollection ( ac) defined using a get/set method, there is no reason you can't set the dataPRovider on your DataGrid in the set method, every time the data is changed.

If you do that, then you most likely will not have to update the properties or displayList of the DatGrid, because the mere fact of replacing the dataProvider will do it for you.

Something like this:

private var _ac : ArrayCollection;
public function get ac():ArrayCollection){
 return this._ac;
}

public function set ac(value:ArrayCollection){
 this._ac = value;
 this.dataGrid.dataProvider = this.ac;
}

Bingo, every time that the ac value is updated, so will the dataProvider on the DataGrid.

0

精彩评论

暂无评论...
验证码 换一张
取 消