Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 182683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:58:58+00:00 2026-05-11T14:58:58+00:00

In a Flex DataGrid’s first row, the itemRenderer will initialize twice. Tracing the results

  • 0

In a Flex DataGrid’s first row, the itemRenderer will initialize twice. Tracing the results reveals that the flex framework is possibly creating two instances of the first row’s itemRenderer. In a more complex application, where the itemRenderer contains a data-bound ColorPicker, we’re seeing an infinite loop occur because of this problem. Only the first row’s itemRenderer is initialized twice. Is there a way to override flex’s behavior and stop this from occurring? The following code demonstrates the problem:

Main Application:

<?xml version='1.0' encoding='utf-8'?> <mx:Application xmlns:mx='http://www.adobe.com/2006/mxml' layout='absolute' initialize='on_initialize(event);'> <mx:Script> <![CDATA[ /**  * This experiment shows how the first row's itemrenderer is instantiated/added/initialized twice.  * We've never even noticed this before we found that a data-bound ColorPicker enters a infinite  * loop when it is within an itemRenderer.  */     import mx.collections.ArrayCollection;     import mx.events.FlexEvent;      private var dg_array:Array;     private var dg_arrayCollection:ArrayCollection;      private function on_initialize(event:FlexEvent):void {         dg_array = new Array();         dg_arrayCollection = new ArrayCollection();         dg_arrayCollection.addItem('item 1');         dg_arrayCollection.addItem('item 2');          dg.dataProvider = dg_arrayCollection;     } ]]> </mx:Script> <mx:DataGrid id='dg' width='100%' height='100%' rowCount='5'>     <mx:columns>         <mx:DataGridColumn headerText='Name' itemRenderer='SimpleItemRenderer'/>     </mx:columns> </mx:DataGrid> </mx:Application> 

SimpleItemRenderer:

<?xml version='1.0' encoding='utf-8'?> <mx:Canvas xmlns:mx='http://www.adobe.com/2006/mxml' width='400' height='300' initialize='//on_initialize(event);'> <mx:Script>     <![CDATA[         import mx.events.FlexEvent;          [Bindable]         override public function set data(value:Object):void { _data = value; }                          override public function get data():Object { return _data; }         private var _data:Object;          private function on_initialize_textInput(event:FlexEvent):void {             trace('initialize:event.target='+event.target+', ' + _data); // runs twice, for the first item only          }          private function on_creationComplete_textInput(event:FlexEvent):void {             trace('creationComplete:event.target='+event.target+', ' + _data); // runs twice, for the first item only         }     ]]> </mx:Script> <mx:TextInput text='{data}' id='textInput' initialize='on_initialize_textInput(event);' creationComplete='on_creationComplete_textInput(event);'/> </mx:Canvas> 

Abbreviated Output:

initialize:event.target=ItemRenderers0.dg…SimpleItemRenderer12.textInput, null initialize:event.target=ItemRenderers0.dg…SimpleItemRenderer24.textInput, null creationComplete:event.target=ItemRenderers0.dg…SimpleItemRenderer24.textInput, item 1 initialize:event.target=ItemRenderers0.dg…SimpleItemRenderer29.textInput, null creationComplete:event.target=ItemRenderers0.dg…SimpleItemRenderer29.textInput, item 2 creationComplete:event.target=ItemRenderers0.dg…SimpleItemRenderer12.textInput, item 1

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T14:58:58+00:00Added an answer on May 11, 2026 at 2:58 pm

    Your itemRenderer isn’t really implemented properly, and this might be the cause of your issues

    The overridden set data method should set super.data = value. You do not need to implement your own _data property as the Flex Containers implement IDataRenderer and already have it. I think, without running your code, that you are running into a problem with the cache/recycling.

    What I generally prefer to do is create a [Bindable] private myProperty:Object (usually a custom MyObjectVO that extends EventDispatcher). Then, in my set data method, I will set super.data = value followed by if(value!=null) myProperty=value.

    This allows me to strongly type my actual data, leave the mechanisms intact in regards to the IDataRenderer interface implemented by the Canvas (or other container) and insures that the data is properly recycled.

    Initialize ad creationComplete are poor evets in itemRenderers because they are actually recycled and these methods do not behave as one might expect or want them to.

    I can’t express how beneficial this series by Peter Ent on itemRenders was for me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 123k
  • Answers 123k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer See Google Maps API Range Limiting for an article on… May 12, 2026 at 1:12 am
  • Editorial Team
    Editorial Team added an answer TFS allows merge a changeset. May 12, 2026 at 1:12 am
  • Editorial Team
    Editorial Team added an answer It gets cleared whenever the computer gets "cleaned up". This… May 12, 2026 at 1:12 am

Related Questions

In a Flex DataGrid's first row, the itemRenderer will initialize twice. Tracing the results
In Flex I'm using the following code to allow sorting in a DataGrid (the
I have an xml file providing data for a datagrid in Flex 2 that
How do you bind the dataprovider of a DataGrid in Flex to an Array?
I've got a Flex 3 application with an HTTPService returning an Atom feed. I

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.