3 Replies Latest reply on May 21, 2010 8:54 AM by -BoNzO-

    Bouton.enabled = false; doesn't work

    dhifallah

      hi ,

      I have a datagrid in witch i put button in some culomns.

      I want that when I press a button in one culomn the other buttons in others culmns are disactivated.

      I tried this code , but I have the following error: id attribute is not allowed on the root tag of a component.

       

       

      <mx:DataGridColumn

       

       

      headerText="Global" dataField="bouton_global" editable="false" width="80">

       

       

      <mx:itemRenderer>

       

      <mx:Component>

       

      <mx:Button label="B_Global" width="80" id="BoutonGlobal" height="30" click="document.doo1();"/>

       

      </mx:Component>

       

      </mx:itemRenderer>

       

       

      </mx:DataGridColumn>

       

        

       

       

      <mx:DataGridColumn headerText="Métier" dataField="metier" editable="false" width="80" >

       

       

      <mx:itemRenderer>

       

      <mx:Component>

       

      <mx:Button label="B_Métier" width="80" id="BoutonMetier" height="30" click="document.doo2();"/>

       

      </mx:Component>

       

      </mx:itemRenderer>

       

       

      </mx:DataGridColumn>

       

       

       

      and in my AS:

       

      public function doo1(): void

      {

       

      BoutonMetier.enabled = false;

      Alert.show("coucou1");

      }

       

      public function doo2(): void

      {

      BoutonGlobal.enabled=false;

      Alert.show("coucou2");

      }

       

      Can you help me plz

       

       

       

       

       

       

       

       

       

        • 1. Re: Bouton.enabled = false; doesn't work
          -BoNzO- Level 2

          Bonjour,

           

          The error is correct (!) you are trying to give an id to a root document, even if it's generated by the <mx:component> tag.

           

          A quick way to unstuck you I can think of is :

           

          Declare 2 bindable properties :

           

          [Bindable]

          private boutonMetierEnabled : Boolean;

           

          [Bindable]

          private boutonGlobalEnabled : Boolean;

           

          bind to it and update these in the appropriate places.

           

          Cheers

          • 2. Re: Bouton.enabled = false; doesn't work
            dhifallah Level 1

            Thank you for your reply .

            I tried this:

            in my script :

            [

             

            Bindable] private var boutonMetierEnabled:Boolean=true;

            [

            Bindable] private var boutonGlobalEnabled:Boolean=true;

             

            then

             

            <mx:DataGridColumn

             

             

            headerText="Global" dataField="bouton_global" id="BoutonGlobal1" editable="false" width="80">

             

             

            <mx:itemRenderer>

             

            <mx:Component>

             

            <mx:Button label="B_Global" width="80" height="30" enabled="{(boutonMetierEnabled)?(boutonGlobalEnabled):false}"/>

             

            </mx:Component>

             

            </mx:itemRenderer>

             

             

            </mx:DataGridColumn>

             

            I have the following error:

             

            Multiple markers at this line:

            -1120: Accès à la propriété non définie boutonGlobalEnabled.

            -1120: Accès à la propriété non définie boutonMetierEnabled.

            -1120: Accès à la propriété non définie boutonMetierEnabled.

            -1120: Accès à la propriété non définie boutonGlobalEnabled.

            • 3. Re: Bouton.enabled = false; doesn't work
              -BoNzO- Level 2

              Hi,

               

              Just like you had document.do1, you need to write document.boutonMetierEnabled ( or outerDocument ? Not sure )

               

              And for the bindable expressions, just enabled="{ document.boutonMetierEnabled }" will be enough.