4 Replies Latest reply on Feb 4, 2009 10:07 AM by Newsgroup_User

    Datagrid resets when dataprovider changes

    the_thom
      I have a datagrid's dataprovider that is bound to the lastResult (xmllistcollection) of an httpservice, the httpservice requests every 1 second. Essentially its a constantly updating datagrid.

      Each time the datagrid updates I lose all sorting and selection, almost as if it completely resets each time. Does flex implement something to keep this from happening or am I using the dataprovider incorrectly?

      thanks in advance!
        • 1. Re: Datagrid resets when dataprovider changes
          -Hob Level 1
          You're using the lastResult property improperly. The lastResult object is a brand new object everytime the httpservice gets a new result. The grid is detecting this as a complete refresh of the dataProvider, thus why you're losing your sort, etc...

          The better approach is to handle the result event dispatched by the httpservice when a result comes back, and store the event.result off as a model object somewhere in your application.

          Then on each subsequent call, compare the new result object with what's already in your model, and add to it incrementally.

          Optimally, you would do this by having 2 separate http services. The first one requests the full dataProvider from the server. The 2nd requests updates. That way you don't have to compare 2 xmllists in flex which might be identical. You just include a "last updated datetime" as part of the http request to the server so that the server knows which rows you don't have yet, and can just send you those. It's a much more efficient solution.
          • 2. Re: Datagrid resets when dataprovider changes
            Level 7

            "-Hob" <webforumsuser@macromedia.com> wrote in message
            news:gmaq87$dl7$1@forums.macromedia.com...
            > You're using the lastResult property improperly. The lastResult object is
            > a
            > brand new object everytime the httpservice gets a new result. The grid is
            > detecting this as a complete refresh of the dataProvider, thus why you're
            > losing your sort, etc...
            >
            > The better approach is to handle the result event dispatched by the
            > httpservice when a result comes back, and store the event.result off as a
            > model
            > object somewhere in your application.
            >
            > Then on each subsequent call, compare the new result object with what's
            > already in your model, and add to it incrementally.
            >
            > Optimally, you would do this by having 2 separate http services. The
            > first
            > one requests the full dataProvider from the server. The 2nd requests
            > updates.
            > That way you don't have to compare 2 xmllists in flex which might be
            > identical.
            > You just include a "last updated datetime" as part of the http request to
            > the
            > server so that the server knows which rows you don't have yet, and can
            > just
            > send you those. It's a much more efficient solution.

            If you use a RemoteObject to return typed objects that implement IUID, then
            Flex will recognize the individual items as the same items, but if you keep
            replacing the entire collection at once, then you will continue to have the
            same problem.


            • 3. Re: Datagrid resets when dataprovider changes
              the_thom Level 1
              Our server is only going to be able to return xml objects.

              I was hoping flex could solve this under the table, but if I have to write some code to compare uids and update then i wont complain.

              Thanks for help guys!
              • 4. Re: Datagrid resets when dataprovider changes
                Level 7

                "the_thom" <webforumsuser@macromedia.com> wrote in message
                news:gmcfbk$h2m$1@forums.macromedia.com...
                > Our server is only going to be able to return xml objects.

                Why do you say that? Running ASP classic?