Hi Alex,

Thanks very much for your (as always) valuable insight into how Flex
components actually do their job. I have read your past posts on this list
related to itemRenderers, as well as your blog posts, because I know
itemRenderers are a source of much mystery and misunderstanding to many of
us.

I've been wondering if some measurement issue might be causing re-rendering,
but I didn't know what to look for. I'll check the possibilities you've
suggested to see if they're causing my "loop." If I find something that
might be useful to others, I'll post it back to this thread.

Thanks again for your help, as well as that of all the others who've
answered this thread.


On Mon, Jul 7, 2008 at 4:52 PM, Alex Harui <[EMAIL PROTECTED]> wrote:

>    We don't know how your renderer is set up, but here are some things to
> consider:
>
>
>
> -a variableRowHeight renderer needs to measure() correctly right after the
> data property is set.  Depending on what component is doing word-wrapping,
> the measurements may be fluctuating causing the DG to re-render and recycle
> renderers and re-set their data properties and do more measurements until
> the measurements converge.  Make sure the word-wrapping component's width is
> tied to the column's width.  This is a common error you'll see from my
> responses to past threads.
>
> -you can see if there are multiple rendering passes by setting a breakpoint
> on makeRowsAndColumns.  It should get hit once or twice when the
> dataProvider changes, but not more than that.
>
> -I'd juse array.join() to make your displayable string.
>
>
>  ------------------------------
>
> *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On
> Behalf Of *Tom McNeer
> *Sent:* Monday, July 07, 2008 6:38 AM
> *To:* flexcoders@yahoogroups.com
> *Subject:* [flexcoders] Item renderers cause processor to max out
>
>
>
> Hi,
>
> I began asking about this problem last week and Alex Harui tried to help
> me. But I did such a bad job of explaining my problem, I don't think he
> quite understood the issue.
>
> Also, I've done a lot more work over the weekend, stepping through the
> debugger. And my problem is a bit different than I first thought, anyway.
>
> My application allows users to create multiple sets of product
> configurations. Within each configuration, there are multiple products, each
> with a possibility of multiple options.
>
> Thus, within a Configuration object, there is an itemAC that is a
> collection of product objects. Within each Item/Product object, there is an
> optionArray which holds Option objects. The optionArray cannot be an
> arrayCollection, because the Product objects are VOs populated from a
> RemoteObject, and need to match the signature of a matching object on the
> server.
>
> When the user wishes to view the contents of a Configuration, the itemAC
> (with its collection of Products) becomes the dataProvider of a DataGrid:
>
>        <mx:DataGrid dataProvider="{config.itemAC}" id="configProducts"
> variableRowHeight="true" width="80%" updateComplete="setGridHeight(event)" >
>             <mx:columns>
>                 <mx:DataGridColumn dataField="quantity"
> headerText="Quantity" />
>                 <mx:DataGridColumn dataField="category"
> headerText="Category" />
>                 <mx:DataGridColumn dataField="name" headerText="Product"
> wordWrap="true" />
>                 <mx:DataGridColumn headerText="Options" wordWrap="true"
> itemRenderer="views.OptionList" />
>             </mx:columns>
>         </mx:DataGrid>
>
> However - one cell within the DataGrid needs to display a list of options.
> The user should see these options as a comma-delimited list, essentially,
> not a Flex List element or anything like that. So I have created an
> itemRenderer for the Options column which has a simple function that creates
> the list from the optionArray in the Product which is represented by a row
> in the DataGrid:
>
>            public function setOptionList(options:Array):void{
>                 optionList = "";
>                 for (var i:int = 0;i<options.length;i++){
>                     if (options.length > 1 && i != 0){
>                         optionList = optionList + ', ';
>                     }
>                     optionList += options[i].optionItem;
>                 }
>             }
>
> Since a user may be adding options to a product at any time, the option
> list must update as an option is added.
> I have tried providing the update in various ways. Currently, I am
> overriding the set data function for the itemRenderer component:
>
>             override public function set data(value:Object):void{
>                 if (value != null){
>                     super.data = value;
>                     setOptionList(value.options)
>                 }
>                 dispatchEvent(new FlexEvent(FlexEvent.DATA_CHANGE));
>             }
>
> The symptom of my problem is that once a few products are added, the
> processor pegs and stays there.
>
> My debugging walkthrough has led to find that as products are added (with
> or without options), extra instances of the itemRenderer component seem to
> be generated, and the setOptionList function (triggered by set data) is
> called over and over.
>
> On the first product added, (with an empty option array), two separate
> instances of the itemRenderer component seem to be created. The
> setOptionList function is called three times, showing two unique identifiers
> for views.OptionList components. The function is called on the first
> instance (a), then the second (b), then the first again: a,b,a.
>
> When I add a second product (also with an empty option array, the
> setOptionList function is called 14 times. I can see another instance of
> views.OptionList (c). The setOptionList calls go:
> b,b,a,a,b,c,b,c,a,a,b,c,a,a.
>
> Adding a third product results in 22 calls to the function, on 4 instances.
> The calls go: b,c,b,b,a,a,a,b,c,d,b,c,d,a,a,a,b,c,d,a,a,a.
>
> Can anyone help me understand what's up with all this proliferation?
>
>
> --
> Thanks,
>
> Tom
>
> Tom McNeer
> MediumCool
> http://www.mediumcool.com
> 1735 Johnson Road NE
> Atlanta, GA 30306
> 404.589.0560
>   
>



-- 
Thanks,

Tom

Tom McNeer
MediumCool
http://www.mediumcool.com
1735 Johnson Road NE
Atlanta, GA 30306
404.589.0560

Reply via email to