Well, when a datagrid is initialized it creates as much renderers as 
needed to fill the view.  whenever you supply a dataprovider the data 
field of each renderer gets set!
Now if you add a new item to the dataprovider it and there is an 
empty row in the view it will get displayed by setting the data of 
the renderers in that row.  In your code you only call  myData
(data);  // initializing data
in the init event.  what happens is that when the data changes your 
are not reading it!.  so override the data property and call your 
myData(data) in the setter of that property. 

Another thing, if there is no visible render row that is empty then a 
scrollbar will appear.  What happens when you scroll is that data 
gets shifted up and down using the same set of visible renderers. So 
again reseting your data property need automatically apply the 
changes.
I think another way would be to handle your data_changed event in 
your subcomponent, and reinitialize the data there but i prefer 
overriding the data property. 

Ahmad

--- In [email protected], learner <[EMAIL PROTECTED]> wrote:
>
> Hi all,
> My scenarios is like this :
> My *compDGcontainer  *component is a custom panel .. which get 
initialized
> dynamically. whenevern some event is triggered in code..
> 
> for the first time when it get invoked...the init function of the 
item
> renderer of the DG gets called twice..
> for then on....if i try to add items to the dg by calling function
> addDataToDG... scrollbar appears (which is very fine) ..but it 
displays the
> wrong data.. and also....when i scroll it up and down.. the rows in 
datagrid
> shifts up or down.....behaving very weired..
> this is driving me nuts....can somebody please help
> 
> *compDGcontainer: *
> 
> <MinimizedPanelUtil .....
>   creationComplete="init()" ...../>
> 
>   public function init():void{
>      ......
>      dgDataProvider.addItem(some_obj);
>   }
> 
> *//  this function gets called on some event dispatcher..*
>  public function addDataToDG():void{
>     dgDataProvider.addItem(some_obj);
>  }
> 
>   <mx:DataGrid id="dg" dataProvider="{dgDataProvider}"/>
>    <mx:columns >
>     <mx:DataGridColumn >
>         <mx:itemRenderer>
>                   <mx:Component>
>                            * <message:messageBox/>  //  **custom 
component *
> *used as a  **Item renderer *
>                      </mx:Component>
>          </mx:itemRenderer>
>    </mx:DataGridColumn>
>    </mx:columns>
>   </mx:DataGrid>
> 
> <MinimizedPanelUtil >
> 
> 
> *messageBox.mxml : *
> <mx:Canvas   creationComplete="init()"  .../>
> 
> public function init():void{
>     myData(data);  // initializing data
> }
> 
> 
> 
> Thanks a lot in advance
>


Reply via email to