16 Replies Latest reply on May 26, 2008 8:49 AM by Phread

    Select a dataProvider with a ComboBox

    Phread
      When the user makes a selection from a ComboBox (of a list of subjects), how do I tell the dataProvider of the display element that the dataProvider has changed?

      e.g. <local:DisplayShelf id="shelf" dataProvider="{what_goes_here?}" />
        • 1. Re: Select a dataProvider with a ComboBox
          dietmar.paulus Level 1
          hey

          just the id of the dataProvider should be placed.

          e.g.:

          <mx:ArrayCollection id="arcDP">
          ...
          </mx:ArrayCollection>
          <local:DisplayShelf id="shelf" dataProvider="{arcDP}" />
          • 2. Re: Select a dataProvider with a ComboBox
            Phread Level 1
            hi

            ok so far. but I want something like {arcDP.selectedItem} but that doesn't work.

            Can you help me figure out how to just display the images by subject please?
            • 3. Re: Select a dataProvider with a ComboBox
              dietmar.paulus Level 1
              right this can't work, because an ArrayCollection has no selectedItem, just a list or a datagrid can have a selectedItem, and these lists and datagrids are based on your dataprovider so you can say.

              <Your List>.selectedItem

              or

              <Your DataGrid>.selectedItem

              A ComboBox has a selectedItem too.
              • 4. Re: Select a dataProvider with a ComboBox
                Phread Level 1
                Logically I should be able to use the selectedItem of the ComboBox to tell the Display which data to use. Do I have to filter my ArrayCollection to a new ArrayCollection with just the data about the selected single subject and make that the dataProvider?
                • 5. Re: Select a dataProvider with a ComboBox
                  dietmar.paulus Level 1
                  Hey

                  can you please specifiy your aim of the application and maybe post some code?

                  cheers

                  dietmar
                  • 6. Re: Select a dataProvider with a ComboBox
                    dietmar.paulus Level 1
                    Hey this is a short example:

                    I have a comboBox with a dataprovider and a textAreat which displays the data of the selectedItem of the combobox, if you change the comboBox also the display data is changed.

                    Hope you search for something like this

                    <?xml version="1.0" encoding="utf-8"?>
                    <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
                    layout="absolute"
                    backgroundColor="white">

                    <mx:ComboBox id="cb" dataProvider="{_arcDP}" labelField="name"/>

                    <mx:TextArea top="40" width="100%" height="80"
                    text="{cb.selectedItem.field1 + ';;;' + cb.selectedItem.field2 + ';;;' + cb.selectedItem.field3 + ';;;' + cb.selectedItem.field4}"/>

                    <mx:ArrayCollection id="_arcDP">
                    <mx:Object name="obj1" field1="Test 1 - Field 1" field2="Test 1 - Field 2" field3="Test 1 - Field 3" field4="Test 1 - Field 4"/>
                    <mx:Object name="obj2" field1="Test 2 - Field 1" field2="Test 2 - Field 2" field3="Test 2 - Field 3" field4="Test 2 - Field 4"/>
                    <mx:Object name="obj3" field1="Test 3 - Field 1" field2="Test 3 - Field 2" field3="Test 3 - Field 3" field4="Test 3 - Field 4"/>
                    <mx:Object name="obj4" field1="Test 4 - Field 1" field2="Test 4 - Field 2" field3="Test 4 - Field 3" field4="Test 4 - Field 4"/>
                    </mx:ArrayCollection>

                    <mx:Script>
                    <![CDATA[

                    ]]>
                    </mx:Script>


                    </mx:Application>

                    cheers

                    dietmar
                    • 7. Re: Select a dataProvider with a ComboBox
                      Phread Level 1
                      I get lots of error messages.....

                      warning: unable to bind to property 'field4' on class 'Object' (class is not an IEventDispatcher)
                      • 8. Re: Select a dataProvider with a ComboBox
                        dietmar.paulus Level 1
                        Okay, these are not error messages, these are warnings, and this is just a test-application,

                        if I would programm it in a real appliaction, I would use Objects of a self written class where I have getter and setter methods for my object-fields, so I wouldn't have these error messages.
                        • 9. Re: Select a dataProvider with a ComboBox
                          Phread Level 1
                          Thank you for your help and advice. I missed your earlier question about the application and sample code.
                          See http://demo.quietlyscheming.com/displayShelf/index.html

                          I have hundreds of images which I want to display. I want the user to be able to select a small group of images (by "subject") from a ComboBox. I have tried many solutions but none have worked so far.

                          I have an XML file with the image data.
                          <pre>
                          <photolibrary>
                          <!-- Table images -->
                          <images>
                          <idx>1</idx>
                          <subject>Aerial Views</subject>
                          <date>1820</date>
                          <caption>plan</caption>
                          <filename>di_001.jpg</filename>
                          </images>
                          <images>
                          <idx>2</idx>
                          <subject>Aerial Views</subject>
                          <date>1950s</date>
                          <filename>di_002.jpg</filename>
                          </images>
                          </pre>

                          Does that help?
                          • 10. Re: Select a dataProvider with a ComboBox
                            Phread Level 1
                            Thank you for your help and advice. I missed your earlier question about the application and sample code.
                            See http://demo.quietlyscheming.com/displayShelf/index.html

                            I have hundreds of images which I want to display. I want the user to be able to select a small group of images (by "subject") from a ComboBox. I have tried many solutions but none have worked so far.

                            I have an XML file with the image data.
                            <pre>
                            <photolibrary>
                            <!-- Table images -->
                            <images>
                            <idx>1</idx>
                            <subject>Aerial Views</subject>
                            <date>1820</date>
                            <caption>plan</caption>
                            <filename>di_001.jpg</filename>
                            </images>
                            <images>
                            <idx>2</idx>
                            <subject>Aerial Views</subject>
                            <date>1950s</date>
                            <filename>di_002.jpg</filename>
                            </images>
                            </pre>

                            Does that help?
                            • 11. Re: Select a dataProvider with a ComboBox
                              Phread Level 1
                              Thank you for your help and advice. I missed your earlier question about the application and sample code.
                              See http://demo.quietlyscheming.com/displayShelf/index.html

                              I have hundreds of images which I want to display. I want the user to be able to select a small group of images (by "subject") from a ComboBox. I have tried many solutions but none have worked so far.

                              I have an XML file with the image data.
                              <pre>
                              <photolibrary>
                              <!-- Table images -->
                              <images>
                              <idx>1</idx>
                              <subject>Aerial Views</subject>
                              <date>1820</date>
                              <caption>plan</caption>
                              <filename>di_001.jpg</filename>
                              </images>
                              <images>
                              <idx>2</idx>
                              <subject>Aerial Views</subject>
                              <date>1950s</date>
                              <filename>di_002.jpg</filename>
                              </images>
                              </pre>

                              Does that help?
                              • 12. Re: Select a dataProvider with a ComboBox
                                Phread Level 1
                                Thank you for your help and advice. I missed your earlier question about the application and sample code.
                                See http://demo.quietlyscheming.com/displayShelf/index.html

                                I have hundreds of images which I want to display. I want the user to be able to select a small group of images (by "subject") from a ComboBox. I have tried many solutions but none have worked so far.

                                I have an XML file with the image data.
                                <pre>
                                <photolibrary>
                                <!-- Table images -->
                                <images>
                                <idx>1</idx>
                                <subject>Aerial Views</subject>
                                <date>1820</date>
                                <caption>plan</caption>
                                <filename>di_001.jpg</filename>
                                </images>
                                <images>
                                <idx>2</idx>
                                <subject>Aerial Views</subject>
                                <date>1950s</date>
                                <filename>di_002.jpg</filename>
                                </images>
                                </pre>

                                Does that help?
                                • 13. Re: Select a dataProvider with a ComboBox
                                  Phread Level 1
                                  Thank you for your help and advice. I missed your earlier question about the application and sample code.
                                  See http://demo.quietlyscheming.com/displayShelf/index.html

                                  I have hundreds of images which I want to display. I want the user to be able to select a small group of images (by "subject") from a ComboBox. I have tried many solutions but none have worked so far.

                                  I have an XML file with the image data.
                                  <pre>
                                  <photolibrary>
                                  <!-- Table images -->
                                  <images>
                                  <idx>1</idx>
                                  <subject>Aerial Views</subject>
                                  <date>1820</date>
                                  <caption>plan</caption>
                                  <filename>di_001.jpg</filename>
                                  </images>
                                  <images>
                                  <idx>2</idx>
                                  <subject>Aerial Views</subject>
                                  <date>1950s</date>
                                  <filename>di_002.jpg</filename>
                                  </images>
                                  </pre>

                                  Does that help?
                                  • 14. Re: Select a dataProvider with a ComboBox
                                    Phread Level 1
                                    Thank you for your help and advice. I missed your earlier question about the application and sample code.
                                    See http://demo.quietlyscheming.com/displayShelf/index.html

                                    I have hundreds of images which I want to display. I want the user to be able to select a small group of images (by "subject") from a ComboBox. I have tried many solutions but none have worked so far.

                                    I have an XML file with the image data.
                                    <pre>
                                    <photolibrary>
                                    <!-- Table images -->
                                    <images>
                                    <idx>1</idx>
                                    <subject>Aerial Views</subject>
                                    <date>1820</date>
                                    <caption>plan</caption>
                                    <filename>di_001.jpg</filename>
                                    </images>
                                    <images>
                                    <idx>2</idx>
                                    <subject>Aerial Views</subject>
                                    <date>1950s</date>
                                    <filename>di_002.jpg</filename>
                                    </images>
                                    </pre>

                                    Does that help?
                                    • 15. Re: Select a dataProvider with a ComboBox
                                      Phread Level 1
                                      Thank you for your help and advice. I missed your earlier question about the application and sample code.
                                      See http://demo.quietlyscheming.com/displayShelf/index.html

                                      I have hundreds of images which I want to display. I want the user to be able to select a small group of images (by "subject") from a ComboBox. I have tried many solutions but none have worked so far.

                                      I have an XML file with the image data.
                                      <pre>
                                      <photolibrary>
                                      <!-- Table images -->
                                      <images>
                                      <idx>1</idx>
                                      <subject>Aerial Views</subject>
                                      <date>1820</date>
                                      <caption>plan</caption>
                                      <filename>di_001.jpg</filename>
                                      </images>
                                      <images>
                                      <idx>2</idx>
                                      <subject>Aerial Views</subject>
                                      <date>1950s</date>
                                      <filename>di_002.jpg</filename>
                                      </images>
                                      </pre>

                                      Does that help?
                                      • 16. Re: Select a dataProvider with a ComboBox
                                        Phread Level 1
                                        Thank you for your help and advice. I missed your earlier question about the application and sample code.
                                        See http://demo.quietlyscheming.com/displayShelf/index.html

                                        I have hundreds of images which I want to display. I want the user to be able to select a small group of images (by "subject") from a ComboBox. I have tried many solutions but none have worked so far.

                                        I have an XML file with the image data.
                                        <pre>
                                        <photolibrary>
                                        <!-- Table images -->
                                        <images>
                                        <idx>1</idx>
                                        <subject>Aerial Views</subject>
                                        <date>1820</date>
                                        <caption>plan</caption>
                                        <filename>di_001.jpg</filename>
                                        </images>
                                        <images>
                                        <idx>2</idx>
                                        <subject>Aerial Views</subject>
                                        <date>1950s</date>
                                        <filename>di_002.jpg</filename>
                                        </images>
                                        </pre>

                                        Does that help?