2 Replies Latest reply on Aug 16, 2008 3:40 AM by Ventis85

    Datagrid itemRenderer dynamic values

    Ventis85 Level 1
      While working on an application I came across the following problem. I've got a view with a datagrid, where I have several columns. Each column needs 2 values displayed beneath each other in one cell. You make an itemRenderer with 2 labels inside a VBox. Easy so far. However since this scenario repeats several times it seems counterproductive to make an itemRenderer for each cell. How can I make the text property for the labels change for each cell instead of being static in their values.

      Thx in advance.



        • 1. Re: Datagrid itemRenderer dynamic values
          Gregory Lafrance Level 6
          Your description of your requirements and your sample code do not paint a clear enough picture.

          Your dataProvider has 4 pieces of data: batchId, bookingNumber, valueDate, immsBranch. Your current itemRenderer references two of those pieces of data, and you say you want to reference the other two. You can do that easily like this:

          <mx:Label text="data.valueDate"/>
          <mx:Label text="data.immsBranch"/>

          A basic question: will your DataGrid have two rows for each set of 4 pieces of data? If so then I understand your problem. If not, then you must clarify exactly how and when you would like the 4 pieces of data shown in your DataGrid.

          In any case, you probably need a Repeater, and then need to figure out how to get at the right data at the right time in the Repeater.

          See this FB 3 help topic and its sub-topics:

          Dynamically Repeating Controls and Containers

          Also search for this in the FB3 help to see the API:

          mx.core.Repeater

          You can define a listener for the Repeater for the Repeat event to specify processing for each iteration of the repeater.
          • 2. Re: Datagrid itemRenderer dynamic values
            Ventis85 Level 1
            Actually I want 2 columns with 2 pieces of data in each row. My problem is that I don't want to make an itemRenderer for each column, because every cell in each column basically has 2 labels, only the data changes.

            The reason I need it to be dynamic is because I will have multiple rows, not just one value like in the example. The filled in values are just for testing purposes.

            Thx for your help so far.