4 Replies Latest reply on Jan 5, 2011 12:45 AM by ndgnc66

    prepare() method gridItemRenderer Flex Hero




      last week I installed Flash Builder Burrito to try the new spark dataGrid. I was testing the gridItemRenderer. I wanted to check something form the data and according to the results the item renderer should show three different conditions. But unfortunately I was unable to make the prepare() function work. I did it as was shown in Adobe TV (Deep Dive into Spark DataGrid) but even a trace() was not triggered.


      Is this method not working or am I making something wrong?


      Thanks for your help.

        • 1. Re: prepare() method gridItemRenderer Flex Hero
          jfb00 Level 3


          Where is the adobe TV link?

          Prepare a sample code to show the issue, sory but nobody can guess here.




          • 2. Re: prepare() method gridItemRenderer Flex Hero
            ndgnc66 Level 1

            The Link is:


            http://tv.adobe.com/watch/max-2010-develop/deep-dive-into-the-spark-datagrid-component-and -item-renderers-/


            I created a dataGrid and inserted the following column:


            <s:GridColumn dataField="status" headerText="VP" itemRenderer="itemRenderer.FirstItemRenderer">


            which uses FirstItemRenderer as ItemRenderer. Here the code for FirstItemRenderer:


            <?xml version="1.0" encoding="utf-8"?>

            <s:GridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"







                      import mx.events.FlexEvent;


            // You SHOULD be able to use this method to programatically

            // change the appearance of the data in this cell. However it doesn't

            // seem to be called, yet. Probably a work in progress.

                           override public function prepare( willBeRecycled:Boolean ):void {

                                labelSatus.text = "Result";



                 /* protected function griditemrenderer1_creationCompleteHandler(event:FlexEvent):void



                           labelSatus.text = "Result";

                      } */





                 <s:Label id="labelSatus"/>





            If I use the prepare method, the dataGrid is not populated with the label text "Result". But if I add a creationComplete Event to GridItemRenderer, the dataGrid column is populated with the "Result" text.


            So, my question is am I using the prepare function wrong? Can you show me how to use it to make conditional checks on the data source?


            Thanks in advance,

            • 3. Re: prepare() method gridItemRenderer Flex Hero
              kevinklin Adobe Employee



              Which build of the Flex SDK are you using? There a bug fixed where we weren't calling prepare(). Sorry for the trouble. You can grab a newer build of the SDK here: http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+Hero under the "Hero Builds" section that should have the fix in it.



              • 4. Re: prepare() method gridItemRenderer Flex Hero
                ndgnc66 Level 1

                Hi Kevin,


                thanks for the information. I downloaded the build and it worked. But I had to install Flash Player 10.2 Beta.


                Thanks for the help.