2 Replies Latest reply on Sep 1, 2009 6:20 AM by rahi911

    ItemRenderer: Dynamically change or not use one depending on a condition



      I am using custom ListItemRenderer for displaying format and its images on one of the columns on one of the tabs. But, I have other tabs with the same column but, on this column I just need to display text.


      I have the data in an ArrayCollection of Objects with "format" as the String property. I am using AdvancedDataGridColumn and setting the itemRenderer property on creationComplete.


      The instance where I need to display images and formats, its working fine. However, on the other tabs where I have to display just the format text, I dont see anything.


      Is there a way to dynamically change or not to use the ItemRenderer for the column. I would like to set ItemRenderer based on a condition or status at runtime so that depending on the tab I am at, I want to use the ItemRenderer and on other tabs, I just want to display directly the dataField of "format".


      Any help is very much appreciated.


      Thank You.

        • 2. Re: ItemRenderer: Dynamically change or not use one depending on a condition
          rahi911 Level 1





          function creationCompleteHandler():






          var formatReportItemRenderer:ClassFactory = new ClassFactory(FormatReportItemRenderer);

          formatReportItemRenderer.properties = { reportUrl: Config.getInstance().reportUrl,

          userName: Config.getInstance().userID };

          formatReportColumn.itemRenderer = formatReportItemRenderer;






          width="100%" height="100%"





          <mx:AdvancedDataGrid id="dataGrid" width="100%" height="100%" dataProvider="{reportInstances}" creationComplete="creationCompleteHandler()">












          <mx:AdvancedDataGridColumn headerText="Product" dataField="productName"/>



          <mx:AdvancedDataGridColumn headerText="Format" dataField="format" id="formatReportColumn"





          <!--<mx:AdvancedDataGridColumn headerText="Format" dataField="format" />-->










          As you see, Format column is using an ItemRenderer. But, this format column is on multiple tabs on my screen. I would like to use this ItemRenderer only on of my tabs. But on other tabs, I would like to display the text directly which is under dataField format as specified. Right now, the ItemRenderer works fine on the tab where I want to display image for a format. But, on other tabs where I just want to display the text, I dont see anything.