thanks Ahmad ! I got it reading it from http://blogs.adobe.com/aharui/2007/03/thinking_about_item_renderers_1.html
but somehow..adding datagrid to my application makes it slow ..if there are multiple columns (5 in my case )and each column contains minimum 4 UI controls .. On Dec 3, 2007 10:33 AM, ahmad_hamid_cme <[EMAIL PROTECTED]> wrote: > 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] <flexcomponents%40yahoogroups.com>, > 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 > > > > >
