Hi,
Try calling validateNow on the DG after setting the DP source.
Or you might have to actually change the DP to a new HierarchicalData.
cheers,
hworke wrote:
> Hi I am trying to change the dataprovider of a
> advanced datagrid where I am using HierarchicalData
> as data provider. My ADG code is this:
>
> <mx:AdvancedDataGrid width="20%" height="50%">
> <mx:dataProvider>
> <mx:HierarchicalData id="HD" source="{dpHierarchy}"/>
> </mx:dataProvider>
> <mx:columns>
> <mx:AdvancedDataGridColumn dataField="Region"/>
> </mx:columns>
> </mx:AdvancedDataGrid>
>
> I tried to switch the dataprovider as HD.source = anotherArray;
> But it did not work. Here I am attaching the code if that
> helps to find the mistake.
>
>
> ***************************************************************
> ***************************************************************
> ***************************************************************
>
> <?xml version="1.0"?>
> <!-- dpcontrols/adg/SimpleHierarchicalADG.mxml -->
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
>
> <mx:Script>
> <![CDATA[
> import mx.collections.ArrayCollection;
>
> //include "SimpleHierarchicalData.as";
> [Bindable]
> private var dpHierarchy:ArrayCollection = new
> ArrayCollection([
> {Region:"Southwest", children: [
> {Region:"Arizona", children: [
> {Region:"Barbara Jennings", Actual:38865,
> Estimate:40000},
> {Region:"Dana Binn", Actual:29885,
> Estimate:30000}]},
> {Region:"Central California", children: [
> {Region:"Joe Smith", Actual:29134,
> Estimate:30000}]},
> {Region:"Nevada", children: [
> {Region:"Bethany Pittman", Actual:52888,
> Estimate:45000}]},
> {Region:"Northern California", children: [
> {Region:"Lauren Ipsum", Actual:38805,
> Estimate:40000},
> {Region:"T.R. Smith", Actual:55498,
> Estimate:40000}]},
> {Region:"Southern California", children: [
> {Region:"Alice Treu", Actual:44985,
> Estimate:45000},
> {Region:"Jane Grove", Actual:44913,
> Estimate:45000}]}
> ]}
> ]);
>
> [Bindable]
> private var dpHierarchy1:ArrayCollection = new
> ArrayCollection([
> {Region:"Southwest1", children: [
> {Region:"Arizona", children: [
> {Region:"Barbara Jennings", Actual:38865,
> Estimate:40000},
> {Region:"Dana Binn", Actual:29885,
> Estimate:30000}]},
> {Region:"Central California", children: [
> {Region:"Joe Smith", Actual:29134,
> Estimate:30000}]},
> {Region:"Nevada", children: [
> {Region:"Bethany Pittman", Actual:52888,
> Estimate:45000}]},
> {Region:"Northern California", children: [
> {Region:"Lauren Ipsum", Actual:38805,
> Estimate:40000},
> {Region:"T.R. Smith", Actual:55498,
> Estimate:40000}]},
> {Region:"Southern California", children: [
> {Region:"Alice Treu", Actual:44985,
> Estimate:45000},
> {Region:"Jane Grove", Actual:44913,
> Estimate:45000}]}
> ]}
> ]);
> ]]>
> </mx:Script>
>
> <mx:AdvancedDataGrid width="20%" height="50%">
> <mx:dataProvider>
> <mx:HierarchicalData id="HD" source="{dpHierarchy}"/>
> </mx:dataProvider>
> <mx:columns>
> <mx:AdvancedDataGridColumn dataField="Region"/>
> </mx:columns>
> </mx:AdvancedDataGrid>
> <mx:Button label="Button" click="HD.source = dpHierarchy"/>
> <mx:Button label="Button" click="HD.source = dpHierarchy"/>
> </mx:Application>
>
>
>