2 Replies Latest reply on Feb 8, 2011 12:31 AM by afxgroup1976

    Spark list and vertical scrollbar

    afxgroup1976

      Hi,

      i have this problem (that seems a common problem):

       

      I have a List that is bound with an ArrayCollection that is populated with a push data provider that send to me a sport event (with a lot of properties).

      I have also an event map where i put the event into (a simply hashtable).

      If the event doesn't exists in the map i'll add to an ArrayCollection, if the event exists i'll change only its properties (a code snippet):

       

      var event:LiveEvent = tableMap[changedEvent.row_id];
                               
      if (event) {
           if (changedEvent.active==false) {
                events.removeItemAt(getEventByRowId(events,event.row_id));
                tableMap[changedEvent.row_id]=null;
           }
           else {
                var i:Number;
                event.signgroups = changedEvent.signgroups;
                event.name = changedEvent.name;
                event.betstatus=changedEvent.betstatus;
      
      

       

      after this i force a refresh to the dataprovider (events.refresh();) that cause the verticall scroll bar of the list to jump up.

      I've read into a previous post (that was using a datagrid and not a list) that the refresh is needed only when thare are new UID, so in my case if only the properties changed its value it "should" not needed. But if i don't put the refresh my list is not updated.

      I've also tried to get/set the vertical scroll bar position using:

       

      eventList.scroller.verticalScrollBar.value = myOldPosition

       

      but there is someone (i bet some events) that change the scrollbar position after my function.

      How i can prevent to change the scrollbar position or (would be great) avoid the refresh() call?

      this is my list definition:

       

      <s:List dataProvider="{events}" changing="setItem()" id="eventList" width="300" itemRenderer="itemsrenders.EventItemrender" height="{this.height-90}">