8 Replies Latest reply on Jan 6, 2011 11:51 AM by Zolotoj

    Spark DataGrid and custom combobox

    Zolotoj Level 3

      I am trying to

      have a column with a dropdownlist. I am setting up an ItemRenderer at the run time.

      var PersonnelPerson:ClassFactory = new ClassFactory(sparkComboRendererDataGrid);

       

      PersonnelPerson.properties = {labelField : "person", dataProvider : XMLListCollection(dataList.consistcrew)};

       

      dataList.consistcrew as following:

          <consistcrew>
              <person>Conductor</person>
              <id>1</id>
          </consistcrew>
          <consistcrew>
              <person>Engineer</person>
              <id>2</id>
          </consistcrew>
          <consistcrew>
              <person>Helper</person>
              <id>3</id>
          </consistcrew>

       

      and a fragment of sparkComboRendererDataGrid:

       

          import mx.controls.listClasses.BaseListData;
          import mx.controls.listClasses.IDropInListItemRenderer;
         
          import spark.components.ComboBox;
         
          public class sparkComboRendererDataGrid extends ComboBox implements IDropInListItemRenderer
          {
              public function sparkComboRendererDataGrid()
              {
                  super();
              }
             
              public function get listData():BaseListData
              {
                  return null;
              }
             
              public function set listData(value:BaseListData):void
              {
              }
            
          }

       

      I am getting an error:

      Error #1034: Type Coercion failed: cannot convert XMLList@b5068e1 to mx.collections.XMLListCollection

       

      Please help.

       

      Thanks

        • 1. Re: Spark DataGrid and custom combobox
          Gregory Lafrance Level 6

          Try this:

           

          PersonnelPerson.properties = {labelField : "person", dataProvider : new XMLListCollection(dataList.consistcrew)};

           

          If this post answers your question or helps, please mark it as such. Thanks!

          http://www.stardustsystems.com
          Adobe Flex Development and Support Services

          • 2. Re: Spark DataGrid and custom combobox
            Zolotoj Level 3

            It worked, but now I am getting the folowing:

             

            Error: Required skin part openButton cannot be found.
                atspark.components.supportClasses::SkinnableComponent/findSkinParts()[E:\dev\hero_private _beta\frameworks\projects\spark\src\spark\components\supportClasses\SkinnableComponent.as: 671]
                atspark.components.supportClasses::SkinnableComponent/attachSkin()[E:\dev\hero_private_be ta\frameworks\projects\spark\src\spark\components\supportClasses\SkinnableComponent.as:646 ]
                atspark.components.supportClasses::SkinnableComponent/validateSkinChange()[E:\dev\hero_pr ivate_beta\frameworks\projects\spark\src\spark\components\supportClasses\SkinnableComponen t.as:406]
                atspark.components.supportClasses::SkinnableComponent/commitProperties()[E:\dev\hero_priv ate_beta\frameworks\projects\spark\src\spark\components\supportClasses\SkinnableComponent. as:420]
                atspark.components.supportClasses::ListBase/commitProperties()[E:\dev\hero_private_beta\f rameworks\projects\spark\src\spark\components\supportClasses\ListBase.as:808]
                atspark.components::List/commitProperties()[E:\dev\hero_private_beta\frameworks\projects\ spark\src\spark\components\List.as:954]
                atspark.components.supportClasses::DropDownListBase/commitProperties()[E:\dev\hero_privat e_beta\frameworks\projects\spark\src\spark\components\supportClasses\DropDownListBase.as:5 04]
                atspark.components::ComboBox/commitProperties()[E:\dev\hero_private_beta\frameworks\proje cts\spark\src\spark\components\ComboBox.as:644]
                atmx.core::UIComponent/validateProperties()[E:\dev\hero_private_beta\frameworks\projects\ framework\src\mx\core\UIComponent.as:8095]
                atmx.managers::LayoutManager/validateClient()[E:\dev\hero_private_beta\frameworks\project s\framework\src\mx\managers\LayoutManager.as:934]
                atmx.core::UIComponent/validateNow()[E:\dev\hero_private_beta\frameworks\projects\framewo rk\src\mx\core\UIComponent.as:7953]
                atspark.components.supportClasses::GridLayout/layoutItemRenderer()[E:\dev\hero_private_be ta\frameworks\projects\spark\src\spark\components\supportClasses\GridLayout.as:1808]
                atspark.components.supportClasses::GridLayout/createTypicalItemRenderer()[E:\dev\hero_pri vate_beta\frameworks\projects\spark\src\spark\components\supportClasses\GridLayout.as:460]
                atspark.components.supportClasses::GridLayout/updateTypicalCellSizes()[E:\dev\hero_privat e_beta\frameworks\projects\spark\src\spark\components\supportClasses\GridLayout.as:514]
                atspark.components.supportClasses::GridLayout/layoutColumns()[E:\dev\hero_private_beta\fr ameworks\projects\spark\src\spark\components\supportClasses\GridLayout.as:570]
                atspark.components.supportClasses::GridLayout/measure()[E:\dev\hero_private_beta\framewor ks\projects\spark\src\spark\components\supportClasses\GridLayout.as:230]
                atspark.components.supportClasses::GroupBase/measure()[E:\dev\hero_private_beta\framework s\projects\spark\src\spark\components\supportClasses\GroupBase.as:1109]
                atmx.core::UIComponent/measureSizes()[E:\dev\hero_private_beta\frameworks\projects\framew ork\src\mx\core\UIComponent.as:8383]
                atmx.core::UIComponent/validateSize()[E:\dev\hero_private_beta\frameworks\projects\framew ork\src\mx\core\UIComponent.as:8307]
                atspark.components::Group/validateSize()[E:\dev\hero_private_beta\frameworks\projects\spa rk\src\spark\components\Group.as:956]
                atmx.managers::LayoutManager/validateSize()[E:\dev\hero_private_beta\frameworks\projects\ framework\src\mx\managers\LayoutManager.as:659]
                atmx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\hero_private_beta\frameworks\ projects\framework\src\mx\managers\LayoutManager.as:793]
                atmx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\hero_private_beta\fra meworks\projects\framework\src\mx\managers\LayoutManager.as:1157]

             

             

            Any idea?

            • 3. Re: Spark DataGrid and custom combobox
              Gregory Lafrance Level 6

              Does your renderer sparkComboRendererDataGrid implement the openButton skin part?

               

              It is the skin part that defines the anchor button.

               

              See this link for an example of skinning the Flex 4 ComboBox:

              http://flex4fun.com/2010/11/30/flex4-combobox-with-icon/

              • 4. Re: Spark DataGrid and custom combobox
                Zolotoj Level 3

                No, it does not. The code is shown in the original post. Should I implement the openButton skin part?

                 

                Thanks

                • 5. Re: Spark DataGrid and custom combobox
                  Gregory Lafrance Level 6

                  I think custom skins must implement all required skin parts.

                  • 6. Re: Spark DataGrid and custom combobox
                    Zolotoj Level 3

                    But I am not doing any custon skin. I am confused by what's a minimum of code to have in order to create a custom combobox for dataGrid's column.

                    • 7. Re: Spark DataGrid and custom combobox
                      Gregory Lafrance Level 6

                      Hmmm... Not sure about this new error. Might want to start a new post so the title attracts people who can respond better.

                      1 person found this helpful
                      • 8. Re: Spark DataGrid and custom combobox
                        Zolotoj Level 3

                        I got it working and proceeding with functional development. Particularly, I need to populate Grid's dataProvider with the selected from the dropdown value. In my previous projects I was using somehting like this:

                        private function onDataChange(event:Event):void
                                  {
                                       
                                       // set selected value back to DataGrid
                                       DataGrid(listData.owner).selectedItem[DataGrid(listData.owner).columns[listData.columnIndex].dataField] = 
                                       event.target.selectedItem[DataGrid(listData.owner).columns[listData.columnIndex].dataField];
                                  }
                        

                         

                        But now it complaines that listData is null. I have checked:

                        public function set listData(value:BaseListData):void
                                  {
                                       trace("ListData: " + value);
                                       _listData = value;
                                  }
                        

                         

                        and I dont see any tracking. Could you please help me to understand why the setter is not called?

                         

                        Thanks