13 Replies Latest reply on Dec 10, 2008 6:03 PM by Newsgroup_User

    Itemrenderer Data is not passed to the outer document

    nikos101 Level 2
      I have an item renderer that generates an alert but the data is not passed to the outer document?

      Any ideas how to work around this?

        • 1. Re: Itemrenderer Data is not passed to the outer document
          nikos101 Level 2
          I think I know where the problem may lie, As far as I know there is no way for an custom item renderer in a datagrid to know what row it is in and hence access the data from the datagrids dataprovider.
          • 2. Re: Itemrenderer Data is not passed to the outer document
            ntsiii Level 3
            No, that is not correct.

            The problem is interactive itemRenderers are quite complex and are tightly integrated with the frameork in order to optimize performance.

            Typically, one must override the set data() method and store the item data locally. Then one calls invalidateProperties. Visual properties should be set in commitProperties(), and children should be created in updateDisplayList.

            If you didn't understand much of that, you see what I mean.

            I advise never starting an item renderer from scratch. Rather find on that is close to what you want and modify it. I have done many, and never start from scratch.

            There are very many examples available.

            Tracy
            • 3. Re: Itemrenderer Data is not passed to the outer document
              rtalton Level 4
              Within confirmDeleteDealHandler, can't you simply access the List's selectedIndex property, and then delete that item in the dataprovider?
              • 4. Re: Itemrenderer Data is not passed to the outer document
                nikos101 Level 2
                quote:

                Originally posted by: rtalton
                Within confirmDeleteDealHandler, can't you simply access the List's selectedIndex property, and then delete that item in the dataprovider?



                I'm not sure how as the itemRenderer is an image(Basically a nice red cross) and doesn't seem to hold any reference to the row.
                • 5. Re: Itemrenderer Data is not passed to the outer document
                  Level 7

                  "nikos101" <webforumsuser@macromedia.com> wrote in message
                  news:ghmqfh$h3n$1@forums.macromedia.com...
                  >
                  quote:

                  Originally posted by: rtalton
                  > Within confirmDeleteDealHandler, can't you simply access the List's
                  > selectedIndex property, and then delete that item in the dataprovider?

                  >
                  >
                  > I'm not sure how as the itemRenderer is an image(Basically a nice red
                  > cross)
                  > and doesn't seem to hold any reference to the row.

                  The itemRenderer's data property will contain a reference to the row.


                  • 6. Re: Itemrenderer Data is not passed to the outer document
                    rtalton Level 4
                    Good morning, Amy!
                    I'm trying to find the row reference you mention within the data property of a simple inline itemRenderer (I've included the simplified code below). I'm not seeing the row property; can you help me understand where it is found/accessed? Maybe an inline component doesn't include this property in its click event? I'm looking in the wrong place/event perhaps?
                    Thanks for any enlightenment!
                    • 7. Re: Itemrenderer Data is not passed to the outer document
                      Level 7

                      "rtalton" <webforumsuser@macromedia.com> wrote in message
                      news:ghon4u$sk$1@forums.macromedia.com...
                      > Good morning, Amy!
                      > I'm trying to find the row reference you mention within the data property
                      > of a
                      > simple inline itemRenderer (I've included the simplified code below). I'm
                      > not
                      > seeing the row property; can you help me understand where it is
                      > found/accessed?
                      > Maybe an inline component doesn't include this property in its click
                      > event? I'm
                      > looking in the wrong place/event perhaps?
                      > Thanks for any enlightenment!
                      >
                      > <?xml version="1.0" encoding="utf-8"?>
                      > <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
                      > layout="absolute">
                      > <mx:Model id="mystates">
                      > <states>
                      > <state label="Alabama" abbrev="AL"/>
                      > <state label="Alaska" abbrev="AK"/>
                      > <state label="Arizona" abbrev="AZ"/>
                      > <state label="Arkansas" abbrev="AR"/>
                      > <state label="California" abbrev="CA"/>
                      > <state label="Colorado" abbrev="CO"/>
                      > <state label="Connecticut" abbrev="CT"/>
                      > </states>
                      > </mx:Model>
                      >
                      > <mx:List id="myList"
                      > dataProvider="{mystates.state}"
                      > height="101" width="151">
                      > <mx:itemRenderer>
                      > <mx:Component>
                      > <mx:Text text="{data.abbrev}">
                      > <mx:click>
                      > <![CDATA[
                      > trace("where's the row?");
                      > ]]>
                      > </mx:click>
                      > </mx:Text>
                      > </mx:Component>
                      > </mx:itemRenderer>
                      > </mx:List>
                      >
                      > </mx:Application>

                      Try this:

                      1) Put a break point next to the trace statement
                      2) Click the little debug button, let it switch to debug mode
                      3) Switch to the variables pane (I put mine in the same group as the Flex
                      Navigator pane, because I like having more vertical space there).
                      4) Click the + sign next to "event"
                      5) Click the + sign next to "inherited"
                      6) Click the + sign next to "currentTarget"
                      7) Click the + sign next to "inherited"
                      8) Click the + sign next to "data"

                      What do you see?

                      HTH;

                      Amy


                      • 8. Re: Itemrenderer Data is not passed to the outer document
                        rtalton Level 4
                        Here's what is shown at that "key":
                        • 9. Re: Itemrenderer Data is not passed to the outer document
                          rtalton Level 4
                          Note:
                          I can see the rowIndex prop in:
                          event.currentTarget.listData.rowIndex

                          But I'm not sure if this prop is accurate (re: row position in the dataProvider) as itemRenderers are being recycled as the list scrolls. Still confused about that one.
                          • 10. Re: Itemrenderer Data is not passed to the outer document
                            Level 7

                            "rtalton" <webforumsuser@macromedia.com> wrote in message
                            news:ghopsu$482$1@forums.macromedia.com...
                            > Here's what is shown at that "key":
                            >
                            >
                            > event.currentTarget.data = mx.utils.ObjectProxy (@4005c59)
                            > abbrev = "AZ"
                            > label = "Arizona"
                            > object = Object (@41f28f9)
                            > abbrev = "AZ"
                            > label = "Arizona"
                            > type = null
                            > uid = "7039945E-922F-84E1-0433-21AAE55AE818"

                            ...which is a reference to the record being displayed by the renderer that
                            was clicked.


                            • 11. Re: Itemrenderer Data is not passed to the outer document
                              rtalton Level 4
                              Thanks, right, I got that. But I'm assuming nikos101 wants to delete that record from the dataProvider and so needs the index in the dataProvider. Is event.currentTarget.listData.rowIndex a reliable way to access a dataProvider item for deletion? The help docs seem to indicate that the rowIndex prop of a ListEvent is only relevant to the itemRender, not the dataProvider.
                              • 12. Re: Itemrenderer Data is not passed to the outer document
                                nikos101 Level 2
                                It should work as the row index correlates exacty with the data provider, I think you are getting confused with the dataprovider.source.
                                • 13. Re: Itemrenderer Data is not passed to the outer document
                                  Level 7

                                  "rtalton" <webforumsuser@macromedia.com> wrote in message
                                  news:ghp187$d4g$1@forums.macromedia.com...
                                  > Thanks, right, I got that. But I'm assuming nikos101 wants to delete that
                                  > record from the dataProvider and so needs the index in the dataProvider.
                                  > Is
                                  > event.currentTarget.listData.rowIndex a reliable way to access a
                                  > dataProvider
                                  > item for deletion? The help docs seem to indicate that the rowIndex prop
                                  > of a
                                  > ListEvent is only relevant to the itemRender, not the dataProvider.

                                  The data property on the itemRenderer contains the item itself. Most
                                  collections will let you delete an item from them if you just know the item
                                  and not the index.