2 Replies Latest reply on Jan 12, 2012 8:39 AM by Abhishek Chaudhary

    Re-usable Item-renderers

    Abhishek Chaudhary Level 1

      Can we create re-usable item renderers in flex?

       

      Like If I have 10 datagrids having different dataproviders

       

      I want to display any one column in every datagrid as a link button, can I do it using only one item renderer?

       

      Regards,

      Abhishek

        • 1. Re: Re-usable Item-renderers
          Abhishek Chaudhary Level 1

          Can anyone plz reply....

          • 2. Re: Re-usable Item-renderers
            Abhishek Chaudhary Level 1

            Wel no one replied..

             

            I got answer and posting same..

             

             

            /////////////////////////////////////////////////////////////////

            lnBtnItemRenderer

            ////////////////////////////////////////////////////////////////

             

             

            package com.nol.atplan.reportresult.view

            {

                      import flash.events.MouseEvent;

             

                      import mx.containers.HBox;

                      import mx.controls.CheckBox;

             

             

                      public class CheckBoxRenderer extends HBox {

                      

                       [Bindable]

                       private var selectedItem:Object;

                       private var chbox:CheckBox;

                      

                       public function CheckBoxRenderer() {

                                super();

                                chbox = new CheckBox();

                                 chbox.addEventListener(MouseEvent.CLICK,onChangeHandler);

                       }

             

                       override public function set data(value:Object):void{

                                selectedItem = value;

                                if(value!=null) {

                                      if(value.Flag == false) {

                                                chbox.selected=false;

                                      } else if(value.Flag == true) {

                                                chbox.selected=true;

                                      }

                                  }

                            addChild(chbox);

                 }

                           

                      }

            }

             

             

             

            ////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////

            objCol is advanced datagrid col !!

             

            var colRendererFactory:ClassFactory = new ClassFactory(lnBtnItemRenderer);

                                                              colRendererFactory.properties={columnName:datagridDetails[i].hea derText};

                                                              objCol.itemRenderer=colRendererFactory;