5 Replies Latest reply on May 7, 2008 9:59 PM by Linh đẹp trai

    item editor for catch event.

    Level 1
      I make the app, it used data grid editor item is combo box, if i want to catch event 'change' of ComboBox with id="inlineEditor" but i don't known how i can do... ?

      Some body help me, please... !
      Thanks so mucks !

      ps: my English is not well


      with this code :
      //===========================================================
        • 1. Re: item editor for catch event.
          atta707 Level 2
          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
          layout="vertical" width="300" height="300" >

          <mx:Script>
          <![CDATA[
          import mx.collections.ArrayCollection;

          [Bindable]
          private var initDG:ArrayCollection = new ArrayCollection(
          [
          {company:'C1', contact:'Con1', phone:'phone1', city:'City1', state:'state1'},
          {company:'C2', contact:'Con2', phone:'phone2', city:'City2', state:'state2'}
          ]
          );
          ]]>
          </mx:Script>
          <mx:Component id="inlineEditor">
          <mx:ComboBox>
          <mx:change>
          <![CDATA[
          Alert.show('Changed.');
          ]]>
          </mx:change>
          <mx:dataProvider>
          <mx:String>AL</mx:String>
          <mx:String>AK</mx:String>
          <mx:String>AR</mx:String>
          <mx:String>CA</mx:String>
          <mx:String>MA</mx:String>
          </mx:dataProvider>
          <mx:Script>
          <![CDATA[
          import mx.controls.Alert;
          ]]>
          </mx:Script>
          </mx:ComboBox>
          </mx:Component>

          <mx:DataGrid id="myGrid"
          variableRowHeight="true"
          dataProvider="{initDG}"
          editable="true" >
          <mx:columns>
          <mx:DataGridColumn dataField="company" editable="false"/>
          <mx:DataGridColumn dataField="contact"/>
          <mx:DataGridColumn dataField="phone"/>
          <mx:DataGridColumn dataField="city"/>
          <mx:DataGridColumn dataField="state"
          width="150"
          editorDataField="selectedItem"
          itemEditor="{inlineEditor}"/>
          </mx:columns>
          </mx:DataGrid>

          </mx:Application>
          • 2. Re: item editor for catch event.
            Level 1
            <mx:Script>
            <![CDATA[
            import mx.collections.ArrayCollection;

            [Bindable]
            private var initDG:ArrayCollection = new ArrayCollection(
            [
            {company:'C1', contact:'Con1', phone:'phone1', city:'City1', state:'state1'},
            {company:'C2', contact:'Con2', phone:'phone2', city:'City2', state:'state2'}
            ]
            );

            // =========================================================
            public function test():void{
            // do something
            }
            // =========================================================
            ]]>
            </mx:Script>
            <mx:Component id="inlineEditor">
            <mx:ComboBox>
            <mx:change>
            <![CDATA[
            Alert.show('Changed.');
            //======================
            test()
            /*
            this is ERR
            if this did not interfere to outside.
            */
            //======================
            ]]>
            </mx:change>
            <mx:dataProvider>
            <mx:String>AL</mx:String>
            <mx:String>AK</mx:String>
            <mx:String>AR</mx:String>
            <mx:String>CA</mx:String>
            <mx:String>MA</mx:String>
            </mx:dataProvider>
            <mx:Script>
            <![CDATA[
            import mx.controls.Alert;
            ]]>
            </mx:Script>
            </mx:ComboBox>
            </mx:Component>
            • 3. Re: item editor for catch event.
              Level 1
              way...
              some body help me please !
              • 4. Re: item editor for catch event.
                atta707 Level 2
                oh, the outerDocument is what you need to dereference the function and it must not be private.

                ---------------------------------------------------------------------
                <?xml version="1.0" encoding="utf-8"?>
                <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
                layout="vertical" width="300" height="300" >

                <mx:Script>
                <![CDATA[
                import mx.controls.Alert;
                import mx.collections.ArrayCollection;

                [Bindable]
                private var initDG:ArrayCollection = new ArrayCollection(
                [
                {company:'C1', contact:'Con1', phone:'phone1', city:'City1', state:'state1'},
                {company:'C2', contact:'Con2', phone:'phone2', city:'City2', state:'state2'}
                ]
                );

                function outerFunctionTest() : void {
                Alert.show("I'm outside the inlined component!");
                }
                ]]>
                </mx:Script>
                <mx:Component id="inlineEditor">
                <mx:ComboBox>
                <mx:change>
                <![CDATA[
                Alert.show('Changed.');
                outerDocument.outerFunctionTest();
                ]]>
                </mx:change>
                <mx:dataProvider>
                <mx:String>AL</mx:String>
                <mx:String>AK</mx:String>
                <mx:String>AR</mx:String>
                <mx:String>CA</mx:String>
                <mx:String>MA</mx:String>
                </mx:dataProvider>
                <mx:Script>
                <![CDATA[
                import mx.controls.Alert;
                ]]>
                </mx:Script>
                </mx:ComboBox>
                </mx:Component>

                <mx:DataGrid id="myGrid"
                variableRowHeight="true"
                dataProvider="{initDG}"
                editable="true" >
                <mx:columns>
                <mx:DataGridColumn dataField="company" editable="false"/>
                <mx:DataGridColumn dataField="contact"/>
                <mx:DataGridColumn dataField="phone"/>
                <mx:DataGridColumn dataField="city"/>
                <mx:DataGridColumn dataField="state"
                width="150"
                editorDataField="selectedItem"
                itemEditor="{inlineEditor}"/>
                </mx:columns>
                </mx:DataGrid>

                </mx:Application>
                • 5. Re: item editor for catch event.
                  Level 1
                  oh` .... o_o

                  To atta707
                  Thank you very much !
                  this nice code for me, and how can i understand about outerDocument ???

                  Thanks