5 Replies Latest reply on Mar 11, 2010 8:16 AM by jimmyoneshot

    Tricky Problem to do With Populating Combo Boxes

    jimmyoneshot Level 1

      I am currently trying to create an ecommerce website using flex/php/mysql. At the moment I have a selection of categories down the left which filters the product selection on the right. Clicking on a product in the product selection brings up all of the details on that product (an image of it, text, thumbnails etc). The categories and the product selections are each populated by a http request to php files which allow me to display anything within my mysql database in the flex app. This obviously means any changes I make (or more importantly what my client will eventually make) to my mysql database affect the products and categories details etc.

       

      My problem is that each product has a range of options which need to be placed within a dropdown applied to each product and each product has different options. What I need is to populate each of the combo boxes with the details for each option that i have stored within the products table for each product. I've currently assigned all of the details from the products table as the data provider of my tilelist which acts as my product selection and as I mentioned clicking on each of these products brings up the product section I've made with all the details for the chosen product being shown but I simply can't figure out how to get these details into combo boxes as it seems combo boxes require their own dataproviders.

       

      To explain further what I mean one of the products requires 2 combo boxes the first being colour choice (red,green or blue) and the second being shape (square or recetangular) whereas the other prduct requires only 1 combo box to choose sizes from (5 inch, 10 inch or 15 inch).

       

      Can anyone give me any ideas on how I can work this in even if it's not a solution a suggestion as to what might be better would be great as I'm really stuck on this? Cheers for any suggestions.

        • 1. Re: Tricky Problem to do With Populating Combo Boxes
          jimmyoneshot Level 1

          Basically what I'm looking for is how to populate a combo box with DISTINCT values from and array collection. For example in my array collection (productsAC) i have productid, productname, productimage, productdropdownitem1, productdropdownitem2 and productdropdownitem3.

           

          It's only productdropdownitems 1,2 and 3 that I want to display in the combo box.

          • 2. Re: Tricky Problem to do With Populating Combo Boxes
            Ansury Level 3

            No time to read the first post now (sorry) but if your summary is enough, it sounds like you may have a problem with your data model design.

             

            If I understand correctly, you're passing an array with basically non-homogeneous data, which isn't really a good idea.  It sounds like what you should be passing to the Flex client is an Object with those attributes (id, name, image) and then a list (an Array or ArrayCollection) as the last attribute containing the dropdown items.  (I'm guessing a bit because I can't picture what those dropdown items represent.)  Once you do this you can easily just set that list (or a copy) as the backing dataprovider for your combobox. 

             

            Does that sound reasonable?

            1 person found this helpful
            • 3. Re: Tricky Problem to do With Populating Combo Boxes
              jimmyoneshot Level 1

              So it may be my table/database structure that needs ammending? At the moment I have all of my attributes for each product such as product name and description etc including the items that need to be added to their dropdown/comboboxes which I've named itemaname, itembname, itemcname as the column headers and given a different name to each of these items for each individual product all stored within the same table. The best way I can describe what I need is this example:-

               

              http://www.imageproduct.co.uk/acatalog/bathroom_tvs.html

               

              The top product on that site has 2 dropdowns whereas the next one has none. Some products in my site will need 2 dropdowns, others one all with different options contained within the dropdowns. I've also assigned 'addons' to these itemnames in my table like in that website so that hopefully as the user selects a particular item that will add it on to the overall price of the product.

               

              I have 1 product area set up which changes based on what product is clicked within my tilelist for example it has a label and image component at the top and their source changes to the relevant product as each is selected.

              • 4. Re: Tricky Problem to do With Populating Combo Boxes
                jimmyoneshot Level 1

                To better explain hat I have set up now:-

                 

                My column headers in my database of my products table are:- productid, productname, productimage, productdescription, productdropdown1itema, productdropdown1itemb, productdropdown1itemc, productdropdown2itema and productdropdown2itemb.

                 

                The choicesTilelist has been set a dataprovider which is the array collection derived from my mysql database products table. When each product in the tilelist is displayed it's details are shown in the product details section I've made. The products details section contains an image component (productImage) a text box for the description (productDescription) and a text box for the name (productName) as well as the 2 combo boxes (combo1 and combo2)

                 

                And basically when an item is clicked within the choicesTilelist the following code contained in a click function I've made runs:-

                 

                 

                if (choicesTilelist.selectedItem.productimage>0) {productImage.includeInLayout=true; productImage.visible=true; productImage.source=

                 

                if (choicesTilelist.selectedItem.productimage>0) {productImage.includeInLayout=true; productImage.visible=true; productImage.source=

                if (choicesTilelist.selectedItem.productimage>0) {productImage.includeInLayout=true; productImage.visible=true; productImage.source=

                 

                'assets/images/'+ choicesTilelist.selectedItem.productimage;} else {productImage.includeInLayout=false; productImage.visible=false;}

                if (choicesTilelist.selectedItem.productname>0) {productName.includeInLayout=true; productName.visible=true; productName.text=choicesTilelist.selectedItem.productname} else {productName.includeInLayout=false; productName.visible=false;}

                 

                if (choicesTilelist.selectedItem.productdescription>0) {productDescription.includeInLayout=true; productDescription.visible=true; productDescription.text=choicesTilelist.selectedItem.productdescription} else {productDescription.includeInLayout=false; productDescription.visible=false;}

                 

                What I was hoping to be able to do was assign values in this way to the 2 combo boxes and have them appear the way I've done with the other values above i.e. if for example productdropdownitema is blank it will not be added to the combo box but if it is not blank (greater/> than 0) it will be added.

                 

                 

                • 5. Re: Tricky Problem to do With Populating Combo Boxes
                  jimmyoneshot Level 1

                  Can anyone help me out on this or suggest how I may go about setting up this sort of functionality? I'm totally stuck and can't take my app any further until I figure this out. I've searched and can't find the solution anywhere.

                   

                  Overall I'm trying to do this:-

                   

                  - Have a list of categories down the left in a tilelist DONE

                  - When each category is clicked all of the products within that category are displayed on the right in the choices Tilelist DONE

                  - When each product is clicked the product detail section appears containing all of the relevant data for that product DONE

                  - I now need to add dropdowns to the product detail section that change based on what product is clicked and will eventually add to the overall price depending on what one is chosen I'M STUCK HERE

                   

                  If any of you guys were to attempt this how would you go about it bearing in mind all of the data is stored in a my sql database retrieved via php/xml so that it is stored in array collections.