3 Replies Latest reply on Jan 6, 2011 11:57 PM by Sree_D

    how to bind adjacent column on combobox change in data grid

    vineet osho Level 1

      Hi frnds

                    I am working on a data grid application.In this application i have two columns in first column i rendered textinput within item renderer and in second column i render combo box. i just want to bind the textinput in first column with second column combobox's.i means when i select any thing from combox it will automatically set in its adjacent columns text input. is it possible actually i m not getting ids of textinput rendered in data grid column.so how i bind them.please please help me out.

       

      Thanks and regards

           Vineet Osho

        • 1. Re: how to bind adjacent column on combobox change in data grid
          Sree_D Level 2

          You can try having a change handler for combox in the itemrenderer and set the value of the variable (would be a property in data oblect) corresponding to the text input column.

          1 person found this helpful
          • 2. Re: how to bind adjacent column on combobox change in data grid
            vineet osho Level 1

            Hi sree thanks for your quick reply.as directed i get the value of selected

            value of combobox on change event but but couldnt get your point how to set data property for correspoinding text input in renderer present in data grid.hows this possible can u explain me.waiting for reply


            Thanks and regards

                Vineet Osho.

            • 3. Re: how to bind adjacent column on combobox change in data grid
              Sree_D Level 2

              Refer to below example

               

              <?xml version="1.0" encoding="utf-8"?>

              <mx:Application

               

               

              xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="top"

              horizontalAlign="

              center" backgroundGradientColors="[0x000000,0x323232]" paddingTop="0" viewSourceURL="srcview/index.html">

               

               

               

              <mx:Script>

              <![CDATA[

               

               

              import mx.collections.ArrayCollection;

               

              [

              Bindable]

               

              private var dpFlat:ArrayCollection = new ArrayCollection([

              {Region:

              "Southwest", Territory:"Arizona",

              Territory_Rep:

              "Barbara Jennings", Actual:38865, Estimate:40000},

              {Region:

              "Southwest", Territory:"Arizona",

              Territory_Rep:

              "Dana Binn", Actual:29885, Estimate:30000},

              {Region:

              "Southwest", Territory:"Central California",

              Territory_Rep:

              "Joe Smith", Actual:29134, Estimate:30000},

              {Region:

              "Southwest", Territory:"Nevada",

              Territory_Rep:

              "Bethany Pittman", Actual:52888, Estimate:45000},

              {Region:

              "Southwest", Territory:"Northern California",

              Territory_Rep:

              "Lauren Ipsum", Actual:38805, Estimate:40000},

              {Region:

              "Southwest", Territory:"Northern California",

              Territory_Rep:

              "T.R. Smith", Actual:55498, Estimate:40000},

              {Region:

              "Southwest", Territory:"Southern California",

              Territory_Rep:

              "Alice Treu", Actual:44985, Estimate:45000},

              {Region:

              "Southwest", Territory:"Southern California",

              Territory_Rep:

              "Jane Grove", Actual:44913, Estimate:45000},

              {Region:

              "NorthEast", Territory:"New York",

              Territory_Rep:

              "Jose Rodriguez", Actual:26992, Estimate:30000},

              {Region:

              "NorthEast", Territory:"New York",

              Territory_Rep:

              "lisa Sims", Actual:47885, Estimate:50000},

              {Region:

              "NorthEast", Territory:"Massachusetts",

              Territory_Rep:

              "kelly o&apos;connell", Actual:172911, Estimate:20000},

              {Region:

              "NorthEast", Territory:"Pennsylvania",

              Territory_Rep:

              "John Barnes", Actual:32105, Estimate:30000},

              {Region:

              "MidWest", Territory:"Illinois",

              Territory_Rep:

              "Seth Brown", Actual:42511, Estimate:40000}

              ]);

              ]]>

               

              </mx:Script>

               

               

              <mx:Panel title="AdvancedDataGrid Control" layout="vertical" color="0xffffff" borderAlpha="0.15" width="500"

              paddingTop="

              5" paddingRight="10" paddingBottom="10" paddingLeft="10" horizontalAlign="center">

               

              <mx:AdvancedDataGrid id="myADG" width="100%" height="100%" color="0x323232" dataProvider="{dpFlat}" editable="true">

               

               

              <mx:columns>

               

               

              <mx:AdvancedDataGridColumn dataField="Region" itemRenderer="com.frm.ComboBoxItemRenderer" editable="false"/>

               

               

              <mx:AdvancedDataGridColumn dataField="Territory" editable="true"/>

               

               

              </mx:columns>

               

               

              </mx:AdvancedDataGrid>

               

               

               

              </mx:Panel>

              </mx:Application>

               

               

               

               

               

               

              And the item renderer is like below

               

               

              package

               

               

              com.frm

              {

               

              import mx.collections.ArrayCollection;

               

              import mx.controls.AdvancedDataGrid;

               

              import mx.controls.ComboBox;

               

              import mx.events.ListEvent;

               

               

              public class ComboBoxItemRenderer extends ComboBox

              {

              [

              Bindable]

               

              public var cards:ArrayCollection = new ArrayCollection(

              [ {label:

              "Visa", data:1},

              {label:

              "MasterCard", data:2},

              {label:

              "American Express", data:3} ]);

               

               

              public function ComboBoxItemRenderer()

              {

               

              super();

               

              this.addEventListener(ListEvent.CHANGE,changeHandler);

              }

               

              private function changeHandler(event:Event):void {

               

              this.selectedIndex =ComboBox(event.target).selectedIndex;

              data.Territory = ComboBox(event.target).selectedLabel;

               

              var adg:AdvancedDataGrid = event.currentTarget.document.myADG;

              adg.dataProvider.itemUpdated( data,

              "Territory" );

              }

               

               

              protected override function commitProperties () : void {

               

              super.commitProperties();

               

              this.dataProvider=cards;

              }

              }

              }

               

               

              let me know if it helps you