3 Replies Latest reply on Dec 21, 2010 8:05 AM by Xung

    disable checkbox in itemrenderer?????

    rck_Cena77

      Hi,

       

          <mx:list dataProvider="{_incentivesCopy}">   <mx:itemrenderer> <fx:component> <mx:Vbox> <mx:Hbox>

       

                                        <s:CheckBox
                                              id="chkIncentive"
                                              skinClass="Skins.Checkbox2"
                                              selected="@{data.IsSelected}"
                                              visible="{outerDocument.doAllowSelection}"
                                              includeInLayout="{outerDocument.doAllowSelection}"
                                              click="outerDocument.changeSkin(event)"
                                              />

      </mx:Hbox></mx:Vbox> </fx:component>  </mx:itemrenderer>

      </mx:list>

       

       

       

      [Bindable]
                  public function get doAllowSelection():Boolean
                  {
                      if(someObject.showMe==false)
                          _doAllowSelection=false;
                          return _doAllowSelection;
                  }

       

      public function changeSkin(event:MouseEvent):void
                  {
                      this.enabled=false;
                  }

       

       

      when i did this the whole list is disappeared, then i tried using click event   it  disabled the whole list. how can i disable the checkbox only.

       

      thanks for reading this.

        • 1. Re: disable checkbox in itemrenderer?????
          Xung

          Please try:

           

          <mx:List dataProvider="{_incentivesCopy}">  

          <mx:itemRenderer>

          <fx:Component>

          <mx:VBox>

           

          <fx:Script>

          <![CDATA[

          protected function chkIncentive_clickHandler(event:MouseEvent):void

          {

          chkIncentive.enabled = false;

          }

          ]]>

          </fx:Script>

           

          <mx:HBox>

          <s:CheckBox

          id="chkIncentive"

          skinClass="Skins.Checkbox2"

          selected="@{data.IsSelected}"

          visible="{outerDocument.doAllowSelection}"

          includeInLayout="{outerDocument.doAllowSelection}"

          click="chkIncentive_clickHandler(event)"

          />

          </mx:HBox>

          </mx:VBox>

          </fx:Component> 

          </mx:itemRenderer>

          </mx:List>

           

          Andy Xung

          • 2. Re: disable checkbox in itemrenderer?????
            rck_Cena77 Level 1

            Thanks Xung for the reply

             

            if i did like that how can i access the script setters/getters    i tried creating in renderer script but cannot access it, here is the code.

             

            <fx:Script>
                    <![CDATA[
                        import DisplayObjects.*;

                    [Bindable]

                        private var _dataContext:DisplayValuesDTO;

            public function get dataContext():DisplayValuesDTO
                        {
                            return _dataContext;
                        }

             

                        public function set dataContext(value:DisplayValuesDTO):void
                        {
                            _dataContext = value;
                        }

             

            protected function btnClose_clickHandler(event:MouseEvent):void

            {

            UpdatePropertyValues(_incentivesCopy, DataContext.Incentives);

            }

            <mx:List dataProvider="{_incentivesCopy}"> 

            <mx:itemRenderer>

            <fx:Component>

            <mx:VBox>

             

            <fx:Script>

            <![CDATA[import DisplayObjects.*;
                                               
                                                  public var data1:DisplayValuesDTO;
                                               
                                                protected function chkIncentive_clickHandler(event:MouseEvent):void
                                                {
                                                    // herer data1 is referencing to null i tried by setting and getter didn't work, how to access the script here

                                                     //  i want to check the conditon for this but unable to process it .
                                                    if(data1!=null  && data1.ShowGoodGreatPriceRanges==false)
                                                    chkIncentive.enabled=false;
                                                }

            ]]>

            </fx:Script>

             

            <mx:HBox>

            <s:CheckBox

            id="chkIncentive"

            skinClass="Skins.Checkbox2"

            selected="@{data.IsSelected}"

            visible="{outerDocument.doAllowSelection}"

            includeInLayout="{outerDocument.doAllowSelection}"

            click="chkIncentive_clickHandler(event)"

            />

            </mx:HBox>

            </mx:VBox>

            </fx:Component>

            </mx:itemRenderer>

            </mx:List>

             

            thanks for your reply once again.

            • 3. Re: disable checkbox in itemrenderer?????
              Xung Level 1

              Notice that, when you create an event of renderer's component, the script is inner the component. If you want to use other component, use must set it to outer of this script.

               

              Please try:

               

              <fx:Script>
                      <![CDATA[
                          import DisplayObjects.*;

               

                          public var data1:DisplayValuesDTO;   

                          [Bindable]

                          private var _dataContext:DisplayValuesDTO;

                          public function get dataContext():DisplayValuesDTO
                          {
                              return _dataContext;
                          }

               

                          public function set dataContext(value:DisplayValuesDTO):void
                          {
                              _dataContext = value;
                          }

               

                         protected function btnClose_clickHandler(event:MouseEvent):void

                         {

                             UpdatePropertyValues(_incentivesCopy, DataContext.Incentives);

                         }

              ]]>

              </fx:Script>

               

              <mx:List dataProvider="{_incentivesCopy}">

              <mx:itemRenderer>

              <fx:Component>

              <mx:VBox>

               

              <fx:Script>

              <![CDATA[                                  

               

                                                 
                                                  protected function chkIncentive_clickHandler(event:MouseEvent):void
                                                  {
                                                      // herer data1 is referencing to null i tried by setting and getter didn't work, how to access the script here

                                                       //  i want to check the conditon for this but unable to process it .
                                                      //if(data1!=null  && data1.ShowGoodGreatPriceRanges==false)

                                                      //Right here you can use outerDocument.method what you want, the mothod is in the script outer (above), you will create it.

                                                      //Or

                                                      if(outerDocument.data1 != null && outerDocument.data1.ShowGoodGreatPriceRanges==false){
                                                           chkIncentive.enabled=false;

                                                      }
                                                  }

              ]]>

              </fx:Script>

               

              <mx:HBox>

              <s:CheckBox

              id="chkIncentive"

              skinClass="Skins.Checkbox2"

              selected="@{data.IsSelected}"

              visible="{outerDocument.doAllowSelection}"

              includeInLayout="{outerDocument.doAllowSelection}"

              click="chkIncentive_clickHandler(event)"

              />

              </mx:HBox>

              </mx:VBox>

              </fx:Component>

              </mx:itemRenderer>

              </mx:List>

               

              Hope it help you.