4 Replies Latest reply on Mar 5, 2012 1:09 AM by RiccardoB.

    Dropdownlist inside Datagrid



      I'm looking for an example on how to insert a spark Dropdownlist inside a spark Datagrid.


      The Datagrid dataProvider is dynamic: I can add or remove element from it.

      The Dropdownlist dataProvider is the same for every Datagrid row and this dataProvider content is loaded dinamically.


      I've tried to make a custom GridItemRenderer but when I call a .refresh() on Datagrid dataProvider, the Dropdownlists in every row become messed up (the selection is lost or wrong).

        • 1. Re: Dropdownlist inside Datagrid
          Zolotoj Level 3

          You will have to show code for your item renderer.

          • 2. Re: Dropdownlist inside Datagrid
            RiccardoB. Level 1

            I'm trying to have a dropdownlist inside a datagrid that changing it, it changes datagrid dataprovider values (its column and also other).


            Here's the code:



            <?xml version="1.0" encoding="utf-8"?>
            <s:GridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" 
                                xmlns:mx="library://ns.adobe.com/flex/mx" clipAndEnableScrolling="true">
                        import mx.collections.ArrayCollection;
                        import spark.events.IndexChangeEvent;
                        private var dp:ArrayCollection;
                        override public function prepare(hasBeenRecycled:Boolean):void
                                dp = new ArrayCollection(parentApplication.otherDpGeneratedDinamically);
                                dp.addItemAt({val: 0, txt: 'None'}, 0);
                                ddl.dataProvider = dp;
                                ddl.selectedItem = parentApplication.findVal(ddl.dataProvider, data[column.dataField]);
                        private function ddlData_changeHandler(event:IndexChangeEvent):void
                            data.x = ddlFornitori.selectedItem.valore; // this is the "data[column.dataField]" used above
                            data.z = data.x * data.y;
                <s:DropDownList id="ddl" width="80" left="7" top="3" right="7" labelField="txt" change="ddlData_changeHandler(event)"/>
            • 3. Re: Dropdownlist inside Datagrid
              Zolotoj Level 3

              How are specifying item renderers for datagrid columns?

              • 4. Re: Dropdownlist inside Datagrid
                RiccardoB. Level 1

                Zolotoj wrote:


                How are specifying item renderers for datagrid columns?


                like this:



                <s:DataGrid id="table" dataProvider="{dp}" editable="true" gridItemEditorSessionSave="table_gridItemEditorSessionSaveHandler(event)">
                        <s:GridColumn dataField="THISONE" headerText="THISONE" editable="false" itemRenderer="renderers.myItemRenderer"></s:GridColumn>
                        <s:GridColumn dataField="x" headerText="x"></s:GridColumn>
                        <s:GridColumn dataField="y" headerText="y"></s:GridColumn>


                Changing the value of the dropdownlist in THISONE it has to change values in x and y