5 Replies Latest reply on Jan 30, 2009 6:53 AM by Newsgroup_User

    Datagrid itemrenderer causing weird data scrolling behaviour

      I have a datagrid bound to an array for editing and viewing. I have a listener for an ItemEditEnd event which looks at the input, chomps any whitespace and writes back to the itemrenderer the updated string. But... if I then reload the data into the dataprovider the datagrid doesn't render it properly because it retains a memory of the previously edited value and re-displays it on the line below where it was. So repeatedly reloading the data causes edited values to magically scroll themselves downwards in the datagrid!

      I gues this is something to do with itemrenderers being recycled, but I have no idea how to code around it. Any help would be gratefully received. A simplified mock up of the problem is attached.

      Many thanks in advance,

      Steve
        • 1. Re: Datagrid itemrenderer causing weird data scrolling behaviour
          John Hall Level 4
          I played for a while but I'm not well versed in itemrenderer data being thrown around yet. However, if you haven't noticed, there's a rather new article at the Adobe Developer Center for Flex about itemEditors. Maybe something of use in there.
          • 2. Re: Datagrid itemrenderer causing weird data scrolling behaviour
            Nothing new in that article, maybe as the series progresses...

            I have a found a hack around this but it's not the way I want to do it. If I add the itemeditend event listener with a very low priority (-100) so it gets executed after flex has already updated the datagrid I can interact directly with the data, instead of the itemeditor/renderer before the data is updated. This means I can't do a preventUpdate() and force the user to correct the input so is not ideal, but it works in this limited application.

            I did find this: http://livedocs.adobe.com/flex/3/html/help.html?content=celleditor_8.html which has exactly the same case of needing to modify data sent back from an itemeditor. It pokes the modified data back to TextInput(myGrid.itemEditorInstance).text which is the same object as my (event.itemRenderer as TextInput).text. Doesn't work.

            I attach my code for anyone else struggling with this. If anyone has a better solution I'd love to see it.

            Steve



            • 3. Re: Datagrid itemrenderer causing weird data scrolling behaviour
              John Hall Level 4
              I'll be watching the series too as i'm just getting into itemEditors. I'm wondering if it's best to make a custom itemEditor and use the preventDefault then override the set data function of the superclass. This, I'm betting, is something that Amy or Tracy or one of the other componently-experienced people will be able to answer today because it'll be a challenge.
              1 person found this helpful
              • 4. Re: Datagrid itemrenderer causing weird data scrolling behaviour
                John Hall Level 4
                I'm not sure where in the scope chain is but maybe you could use a RegEx validator on the cell and act on the RegExpValidationResult. I agree with you, though, that it's uncomfortable to have to resort to solely lowering priorities or increasing timing as it feels like you're going to run into an instance where it doesn't work.
                1 person found this helpful
                • 5. Re: Datagrid itemrenderer causing weird data scrolling behaviour
                  Level 7

                  "John Hall" <webforumsuser@macromedia.com> wrote in message
                  news:gluuip$br2$1@forums.macromedia.com...
                  > I'll be watching the series too as i'm just getting into itemEditors. I'm
                  > wondering if it's best to make a custom itemEditor and use the
                  > preventDefault
                  > then override the set data function of the superclass. This, I'm betting,
                  > is
                  > something that Amy or Tracy or one of the other componently-experienced
                  > people
                  > will be able to answer today because it'll be a challenge.

                  Sorry, most of what I do with Flex is just displaying. I haven't done that
                  much with the editing side.