7 Replies Latest reply on Jul 30, 2008 2:18 PM by Newsgroup_User

    ItemEditors in DataGrid (can I do this?)

    Level 7
      Hi

      If I have a grid with two columns : column1 and column2 can I have a
      combobox editor for column2 whose content depends on the value of column1?

      Eg
      If column1 is 'Car' the combo in option2 should have "Drive", "Clean",
      "Service" as opions.
      If column 2 is 'Boat' the combo in opiton2 should have "Sail", "Clean",
      "Service", "Sink" as options.

      Please help!

      Thanks very much


        • 1. Re: ItemEditors in DataGrid (can I do this?)
          Level 7

          "Martyn Jones" <noone@somewhere.com> wrote in message
          news:g6pngu$m1h$1@forums.macromedia.com...
          > Hi
          >
          > If I have a grid with two columns : column1 and column2 can I have a
          > combobox editor for column2 whose content depends on the value of column1?
          >
          > Eg
          > If column1 is 'Car' the combo in option2 should have "Drive", "Clean",
          > "Service" as opions.
          > If column 2 is 'Boat' the combo in opiton2 should have "Sail", "Clean",
          > "Service", "Sink" as options.

          If you implement IListItemRenderer, then the data property will contain the
          data for the entire row.

          HTH;

          Amy


          • 2. Re: ItemEditors in DataGrid (can I do this?)
            Level 7
            Thanks for the reply Amy but I'm pretty new to flex and I don't really know
            what to do next. I don't really know how to implement iListItemRenderer -
            when I look on the web it doesn't seem clear how I would influence the
            rendering based on the content on "data"

            If you could make things any clearer I'd be very grateful.


            Martyn



            "Amy Blankenship" <amySpamFilter@magnolia_pleaseNOspam_multimedia.com> wrote
            in message news:g6pt24$rv6$1@forums.macromedia.com...
            >
            > "Martyn Jones" <noone@somewhere.com> wrote in message
            > news:g6pngu$m1h$1@forums.macromedia.com...
            >> Hi
            >>
            >> If I have a grid with two columns : column1 and column2 can I have a
            >> combobox editor for column2 whose content depends on the value of
            >> column1?
            >>
            >> Eg
            >> If column1 is 'Car' the combo in option2 should have "Drive", "Clean",
            >> "Service" as opions.
            >> If column 2 is 'Boat' the combo in opiton2 should have "Sail", "Clean",
            >> "Service", "Sink" as options.
            >
            > If you implement IListItemRenderer, then the data property will contain
            > the data for the entire row.
            >
            > HTH;
            >
            > Amy
            >
            • 3. Re: ItemEditors in DataGrid (can I do this?)
              Level 7

              "Martyn Jones" <noone@somewhere.com> wrote in message
              news:g6q0ak$252$1@forums.macromedia.com...
              > Thanks for the reply Amy but I'm pretty new to flex and I don't really
              > know what to do next. I don't really know how to implement
              > iListItemRenderer - when I look on the web it doesn't seem clear how I
              > would influence the rendering based on the content on "data"
              >
              > If you could make things any clearer I'd be very grateful.

              This was the first link when I did a search on Flex combobox datagrid

              http://blog.flexmonkeypatches.com/2008/02/18/simple-datagrid-combobox-as-item-editor-examp le/

              If it's not what you wanted, all I did was pop open a browser window and
              typed "flex combobox datagrid" in the address bar (without quotes). You can
              probably do similar :-).

              HTH;

              Amy


              • 4. Re: ItemEditors in DataGrid (can I do this?)
                Level 7
                Yes - It was the first link when I did a search too - and I read it - before
                posting to the group.

                it does not do what I want to do and unfortunately the addition of sarcasm
                doesn't make any difference. :-)

                Specifically, I want to change to contents of the combobox depending on
                values in other columns. All the examples I have seen have a static list of
                values in the combobox.

                Thanks

                "Amy Blankenship" <amySpamFilter@magnolia_pleaseNOspam_multimedia.com> wrote
                in message news:g6q25r$4ao$1@forums.macromedia.com...
                >
                > "Martyn Jones" <noone@somewhere.com> wrote in message
                > news:g6q0ak$252$1@forums.macromedia.com...
                >> Thanks for the reply Amy but I'm pretty new to flex and I don't really
                >> know what to do next. I don't really know how to implement
                >> iListItemRenderer - when I look on the web it doesn't seem clear how I
                >> would influence the rendering based on the content on "data"
                >>
                >> If you could make things any clearer I'd be very grateful.
                >
                > This was the first link when I did a search on Flex combobox datagrid
                >
                > http://blog.flexmonkeypatches.com/2008/02/18/simple-datagrid-combobox-as-item-editor-examp le/
                >
                > If it's not what you wanted, all I did was pop open a browser window and
                > typed "flex combobox datagrid" in the address bar (without quotes). You
                > can probably do similar :-).
                >
                > HTH;
                >
                > Amy
                >
                • 5. Re: ItemEditors in DataGrid (can I do this?)
                  Gregory Lafrance Level 6
                  The following code uses an inline itemRenderer and e4x syntax to access the data.
                  • 6. Re: ItemEditors in DataGrid (can I do this?)
                    Level 7

                    "Greg Lafrance" <glafrance@chikaradev.com> wrote in message
                    news:g6qb9i$e6v$1@forums.macromedia.com...
                    > The following code uses an inline itemRenderer and e4x syntax to access
                    > the
                    > data.
                    >
                    > -------- data/ComboBox1.xml ---------
                    > <?xml version="1.0" encoding="utf-8" ?>
                    > <vehicles>
                    > <vehicle name="Car">
                    > <info movement="Drive" green="Clean"/>
                    > </vehicle>
                    > <vehicle name="Boat">
                    > <info movement="Sail" green="Clean"/>
                    > </vehicle>
                    > </vehicles>
                    >
                    > -------- ComboBox1.mxml ----------
                    > <?xml version="1.0"?>
                    > <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
                    > creationComplete="dataRequest.send()">
                    > <mx:Script>
                    > <![CDATA[
                    > import mx.controls.dataGridClasses.DataGridColumn;
                    > import mx.rpc.events.ResultEvent;
                    >
                    > [Bindable]
                    > public var resultObj:Object = new Object();
                    >
                    > private var numItems:int;
                    >
                    > private function resultHandler(event:ResultEvent):void{
                    > resultObj = Object(event.result);
                    > for each (var currItem:XML in resultObj.item){
                    > numItems++;
                    > }
                    >
                    > }
                    > ]]>
                    > </mx:Script>
                    > <mx:HTTPService id="dataRequest" useProxy="false"
                    > resultFormat="e4x" result="resultHandler(event)"
                    > url="data/ComboBox1.xml"/>
                    > <mx:DataGrid id="dg" dataProvider="{resultObj.vehicle}"
                    > allowMultipleSelection="true">
                    > <mx:columns>
                    > <mx:DataGridColumn dataField="@name" headerText="Vehicle Name"
                    > width="150"/>
                    > <mx:DataGridColumn id="info" dataField="@name" headerText="Vehicle
                    > Info"
                    > width="150">
                    > <mx:itemRenderer>
                    > <mx:Component>
                    > <mx:ComboBox dataProvider="{data..info.@*}"/>

                    you'd stick a script tag in here that includes a get data method. Based on
                    what the data is, you'd set the dataprovider conditionally.

                    Helps?


                    • 7. Re: ItemEditors in DataGrid (can I do this?)
                      Level 7
                      Thanks Greg - not exactly what I was looking for but you inspired my
                      eventual solution. Posted here if anyone is interested:

                      <?xml version="1.0" encoding="utf-8"?>
                      <mx:VBox xmlns:mx=" http://www.adobe.com/2006/mxml"
                      verticalScrollPolicy="off"
                      horizontalScrollPolicy="off"
                      implements="mx.managers.IFocusManagerComponent">

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

                      private var _data:Object;

                      // implement the drawFocus() method for the VBox.
                      override public function drawFocus(draw:Boolean):void
                      {
                      cbo.setFocus();
                      } // implement IDataRenderer
                      override public function set data(value:Object):void
                      {
                      if (value != null)
                      {
                      super.data = value;
                      _data = value;
                      setDataProvider();
                      }
                      } [Bindable]
                      public var value:Object;

                      [Bindable]
                      private var prov1:ArrayCollection = null;

                      private function setDataProvider():void
                      {
                      if (_data != null)
                      {
                      if (_data.dt == "Something")
                      {
                      prov1 = new ArrayCollection(["one","two","three"]); }
                      else
                      {
                      prov1 = new ArrayCollection(["four","five","six"]);
                      }
                      } }

                      ]]>
                      </mx:Script>

                      <mx:Binding destination="value" source="cbo.value"/>

                      <mx:ComboBox id="cbo" width="100%" dataProvider="{prov1}"/>

                      </mx:VBox>