Hi Tom

Have you trid using a labelFunction instead of the item renderer?

Kind regards,
Ralf

On Mon, Jul 7, 2008 at 3:37 PM, Tom McNeer <[EMAIL PROTECTED]> wrote:
> 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
>
> 

Reply via email to