3 Replies Latest reply on May 30, 2008 7:18 AM by Doc816

    DataGrid jumps on data refresh

    Doc816
      Hi,

      I have a datagrid control bound to an arraycollection. I also have a timer which updates the arraycollection with new data and call its refresh method every few seconds

      The problem is that the datagrid scrolls to the item that is selected and it looks very jumpy. How can i prevent this from happening?
        • 1. Re: DataGrid jumps on data refresh
          Doc816 Level 1
          I found the solution.

          Instead of using the refresh method, i used itemUpdated, which only updates the items that have changed.

          • 2. Re: DataGrid jumps on data refresh
            harik-BOSS
            I face a similar case, where after ArralCollection is mapped tp Datagrid. Once I remove any item from arraycollection, the Datagrid display gets altered.
            Does using, itemUpdated solve my issue. Please send some sample code.
            • 3. Re: DataGrid jumps on data refresh
              Doc816 Level 1
              Actually, I discovered that I don't have to use itemUpdated() method when binding an arraycollection to a datagrid (notification of data change is sent to the view automatically)...

              What i did instead was simply update the properties of the objects inside of my arraycollection through a loop.


              for(var i:int = 0; i < mainCollection.length; i++){
              var item:Object = mainCollection.getItemAt(i);
              for (var qs:String in anotherCollection ){
              item[qs] = anotherCollection[item.id][qs];
              mainCollection.itemUpdated(item);
              }
              }


              But, since you are ADDING or REMOVING items, I'm not sure how useful the code above will be in helping you figure it out. Since I use it to update the items.