11 Replies Latest reply on Sep 23, 2008 6:22 PM by Newsgroup_User

    Attaching images to a data grid

    SiHoop Level 1
      The code below does two things. The data grid displays images and text. The class is used to generate 3 small circles that are placed next to the data grid. My problem is that I would like to place the small circles into the data grid instead of the graphics. Can anyone explain how I would do this? Thank you!
        • 1. Re: Attaching images to a data grid
          Ventis85 Level 1
          Just use an item renderer.
          • 2. Re: Attaching images to a data grid
            SiHoop Level 1
            I have two follow up questions: First, it appears that there are three fields that must be set for the DataGrid to display the new graphics: dataprovider; dataField; and itemRenderer. Is this correct?

            If so, what information should be placed into each field?
            • 3. Re: Attaching images to a data grid
              Ventis85 Level 1
              Dataprovider is for the datagrid as a whole. It should be your arraycollection or xml like you did in your example.

              Datafield and itemrenderer are for the individual columns. Datafield should be the name of the value you want to display in that column, again like you did in your example.

              With the itemrenderer however, you have two options either you make an external itemrenderer or an inline one. In either case you don't have to set a datafield for that column. If you have an external itemrenderer, the itemrenderer property of the column should be the path to your itemrenderer, else leave it blank.
              • 4. Re: Attaching images to a data grid
                Level 7

                "SiHoop" <webforumsuser@macromedia.com> wrote in message
                news:gb84f5$s93$1@forums.macromedia.com...
                >I have two follow up questions: First, it appears that there are three
                >fields
                > that must be set for the DataGrid to display the new graphics:
                > dataprovider;
                > dataField; and itemRenderer. Is this correct?
                >
                > If so, what information should be placed into each field?

                I went into the Help system and typed in datagrid itemrenderer dataprovider.
                This was the second link that came up
                http://livedocs.adobe.com/flex/3/html/cellrenderer_8.html

                Is your Help system broken?


                • 5. Re: Attaching images to a data grid
                  SiHoop Level 1
                  Unfortunately, this is not the case that I'm working with. The page you reference deals with the case where specific images are being loaded from a file-- however, in my case, the images that I want to load into the datagrid are objects created in the class DrawColors which extends Sprite. I want to load the Sprites into the datagrid. The objects are all referenced in an array titled 'colors'. Is it possible to load a Sprite into a datagrid?
                  • 6. Re: Attaching images to a data grid
                    Level 7

                    "SiHoop" <webforumsuser@macromedia.com> wrote in message
                    news:gb8fpi$cb2$1@forums.macromedia.com...
                    > Unfortunately, this is not the case that I'm working with. The page you
                    > reference deals with the case where specific images are being loaded from
                    > a
                    > file-- however, in my case, the images that I want to load into the
                    > datagrid
                    > are objects created in the class DrawColors which extends Sprite. I want
                    > to
                    > load the Sprites into the datagrid. The objects are all referenced in an
                    > array
                    > titled 'colors'. Is it possible to load a Sprite into a datagrid?

                    Your itemRenderer can literally do anything the class it extends can do. I
                    don't think you can put a Sprite directly in a dataGrid. You'll need to
                    extend something like UIComponent or Canvas.

                    HTH;

                    Amy


                    • 7. Re: Attaching images to a data grid
                      SiHoop Level 1
                      Ventis85,
                      I've been trying to understand what you mean in your last post about how to add a Sprite to a dataGrid. As you can see from the above post, Amy Blankenship thinks that it is not possible to add a Sprite to a dataGrid-- do you think it's possible to do so?
                      • 8. Re: Attaching images to a data grid
                        Level 7

                        "SiHoop" <webforumsuser@macromedia.com> wrote in message
                        news:gb8mig$kp5$1@forums.macromedia.com...
                        > Ventis85,
                        > I've been trying to understand what you mean in your last post about how
                        > to
                        > add a Sprite to a dataGrid. As you can see from the above post, Amy
                        > Blankenship
                        > thinks that it is not possible to add a Sprite to a dataGrid-- do you
                        > think
                        > it's possible to do so?

                        I didn't say that. I said it probably isn't possible to add it DIRECTLY to
                        the dataGrid. I.e. I don't think that a subclass of Sprite can be used as
                        an itemRenderer. If I were doing this and I were writing the itemRenderer,
                        I'd extend UIComponent and just use the drawing features from the graphics
                        object of UIComponent and not involve a Sprite at all. But if it tickles
                        your tummy to use Sprite, you can use a UiComponent and add a Sprite to it.

                        HTH;

                        Amy


                        • 9. Re: Attaching images to a data grid
                          Ventis85 Level 1
                          I'll have to go with the lady here. She has a little (read a lot) more experience than me.
                          • 10. Re: Attaching images to a data grid
                            SiHoop Level 1
                            The code below allows me to use an item renderer to achieve my goal. I would like to write this code as a class instead of using it as a custom component-- I assume that doing so is not particularly difficult, but I get errors why I try to convert it to a Class. Should this be a relatively straightforward task to complete?
                            • 11. Re: Attaching images to a data grid
                              Level 7

                              "SiHoop" <webforumsuser@macromedia.com> wrote in message
                              news:gbbgt5$77f$1@forums.macromedia.com...
                              > The code below allows me to use an item renderer to achieve my goal. I
                              > would
                              > like to write this code as a class instead of using it as a custom
                              > component--
                              > I assume that doing so is not particularly difficult, but I get errors why
                              > I
                              > try to convert it to a Class. Should this be a relatively straightforward
                              > task
                              > to complete?

                              An MXML component is still a class, so you're there.