1 Reply Latest reply on Mar 21, 2011 7:19 AM by Pablo Souza

    Getting selected item from combobox itemrenderer and storing in object

    anandbk Level 1

      Hi Guys,

       

      Can anyone help me in this regard. Its very urgent.

       

      I have a combo box itemrenderer in datagrid column. I want to get the user selected item from the dropdown of the row(s) (User may select values from combo box from multiple rows of datagrid) and corressponding values of all other columns of the rows and store it in an object . Then pass this object to database to update only those rows that user has changed.

      I am able to get the selected item from combo box using "event.currentTarget.selectedItem" and corressponding values of all other columns of the rows using "valueSelect.ID", etc where valueSelect is object which contains data for datagrid. But am stuck up with, how to store the selected item value of the combobox  and corressponding values of all other columns of the rows into an Object ?.

       

      Can anybody help me with sample to store selected item from combobox and its corressponding values of all other columns into an object which i can send to db...?

       

      Kindly help me in this regard.

       

      Thanks,

      Anand.

        • 1. Re: Getting selected item from combobox itemrenderer and storing in object
          Pablo Souza Level 3

          Hi!

           

          Are you using a collection of VO or DTO as the dataprovider of the combobox component?

          If so, have you created some attribute there to control the user's selection in the combobox?

           

          For instance:

           

           private var selected:Boolean = false;

           

          If your solution fits this approach, you may create a new collection that contains just the objects that were selected by the user, it means you can loop through the datagrid's dataprovider and only insert in this new collection those objects that have the attribute "selected" set to true.

           

          For instance:

           

          private function getSelectedRecords(datagridDataProvider:ArrayCollection):ArrayCollection
          {
              var newCollection:ArrayCollection = new ArrayCollection();
              for each (var item:Object in datagridDataProvider)
              {
                  if (item.selected)
                      newCollection.addItem(item)
              }
              
              return newCollection;
          }

           

           

          Afterwards, you may serialize this new collection with your back-end.

           

           

          Hope it helps you!

           

          Cheers,

          @Pablo_Souza