I am workin开发者_C百科g on an application using Flex, Adobe Air. I have a DataGrid with a XML as my DataProvider. During the execution of program my XML is updated. After XML is updated and saved my DataGrid should also get update. I have used Dataprovidername.refresh()
method but it is not working.
after updating the data, try dispatching a collection change event manually:
datagrid.dataProvider.dispatchEvent( new CollectionEvent(CollectionEvent.COLLECTION_CHANGE));
For those of you interested in the internals. The MX Halo DataGrid and AdvanceDataGrids will refresh themselves when they detect modifications to the data provider. This should be automatic. This of-course will only work if you mark the dataprovider as bindable and modify the variable that is the dataprovider itself. It is always a good idea to have your dataprovider as an ICollectionView.
For example, if you specify an "Array" or "XML" as a dataprovider for a datagrid, the datagrid will internally create a new ArrayCollection or XmlListCollection and use that as a dataprovider instead. In this case, adding/removing to the source array is not going to have any impact.
Also, in case you need to "re-draw" the datagrid, you need to call invalidateList() instead. A lot of folks think "invalidateDisplayList()" should do it, but it does not. This applies to all listbased controls (Ones that inherit from ListBase).
Did you make the XML-variable Bindable?:
[Bindable]
private var data:XML...
I have solved my problem of refreshing data grid when data-provider XML is changed....
instead of saving the XML document and loading it to the data-grid data provider i assigned the updated XML Document to the data-provider as a new provider..In this way the refreshing problem, with binding can be solved.
精彩评论