DJ,

Perhaps you could set the verticalScrollPosition on the grid's render event.  I'm not sure if this would work, but it might be worth a try

-TH

private var updateGridVerticalScrollPosition:Boolean = false;
private var gridVerticalScrollPosition:int = 0;  // or use Number instead

"update" button click event function:

gridVerticalScrollPosition = dgDelays.verticalScrollPosition;
updateGridVerticalScrollPosition = true;
// Get Data

dgDelays render event function:

if (updateGridVerticalScrollPosition)
{
   updateGridVerticalScrollPosition = false;
   dgDelays.verticalScrollPosition = gridVerticalScrollPosition;
}

--- In [email protected], "djbrown_rotonews" <[EMAIL PROTECTED]> wrote:
>
> I'm still not having any luck. The reset event is being called
> upstream and processed in my handler, with the proper value of
> prevIndex calculated, but the grid still jumps to the top after the
> data fill:
>
> if (event.kind == CollectionEventKind.RESET) {
> var prevIndex:int = this.dgDelays.verticalScrollPosition;
> trace("prevIndex = ",prevIndex);
> this.dgDelays.verticalScrollPosition=prevIndex;
> }
>
> --- In [email protected], "Deepa Subramaniam"
> dsubrama@ wrote:
> >
> > I'm sorry, I totally misspoke. I meant to say RESET in my
> explanation
> > below.
> >
> >
> >
> > When your collection is filled with new data after a fill() call
> to your
> > DataService, the component bound to that collection will receive a
> > CollectionEvent with kind = RESET. Internally, we re-populate the
> > component with the new data and reset the scroll position to 0.
> >
> >
> > What you can do is add your own collectionChange event handler to
> your
> > collection and upon receiving a RESET, reset the
> verticalScrollPosition
> > to whatever value you've been tracking.
> >
> >
> >
> > private function acHandler(event:CollectionEvent):void
> >
> > {
> >
> > if (event.kind == CollectionEventKind.RESET)
> >
> > dg.verticalScrollPosition = vPos;
> >
> > }
> >
> >
> >
> > There's no need to use the scrollToIndex() method; by setting the
> > verticalScrollPosition property directly, the scrollbar and
> content are
> > update as if the user scrolled to that index.
> >
> >
> >
> > Best,
> >
> > deepa
> >
> > ________________________________
> >
> > From: [email protected]
> [mailto:[EMAIL PROTECTED] On
> > Behalf Of djbrown_rotonews
> > Sent: Wednesday, June 28, 2006 7:21 AM
> > To: [email protected]
> > Subject: [flexcoders] Re: Keeping DataGrid from scrolling to top on
> > update to dataProvider
> >
> >
> >
> > I added a collectionChange event to my XMLListCollection (that's
> the
> > dataProvider for the grid) as follows:
> >
> > public function preserveScrollPosition(event:CollectionEvent):void
> {
> >
> > var prevIndex:int = this.dgDelays.verticalScrollPosition;
> > trace("prevIndex = ",prevIndex);
> > this.dgDelays.scrollToIndex(prevIndex);
> >
> > }
> >
> > and the trace info does give me the value of the currentScroll,
> but
> > the grid still goes back to the top after the data is populated.
> >
> > is refresh() still being called after this guy?
> >
> > --- In [email protected] <mailto:flexcoders%
> 40yahoogroups.com>
> > , "Deepa Subramaniam"
> > <dsubrama@> wrote:
> > >
> > > When the actual data comes in, the DataGrid encounters a REFRESH
> > > collectionChange event and if you look in
> > > ListBase.collectionChangeHandler's REFRESH case, you'll see that
> > the
> > > verticalScrollPosition is set to 0.
> > >
> > > What you need to do is set the scroll position *after* the data
> > has come
> > > in and the DataGrid has processed the REFRESH event.
> > >
> > > -deepa
> > >
> > > -----Original Message-----
> > > From: [email protected] <mailto:flexcoders%
> 40yahoogroups.com>
> >
> > [mailto:[email protected] <mailto:flexcoders%
> 40yahoogroups.com>
> > ] On
> > > Behalf Of djbrown_rotonews
> > > Sent: Tuesday, June 27, 2006 12:42 PM
> > > To: [email protected] <mailto:flexcoders%
> 40yahoogroups.com>
> > > Subject: [flexcoders] Re: Keeping DataGrid from scrolling to top
> on
> > > update to dataProvider
> > >
> > > I actually tried this (my dataProvider for the grid is an
> > > XMLListCollection being populated by a jsp. The grid has custom
> > item
> > > renderers if that's relevant).
> > >
> > > anyhow, I have an "update" button which will call the jsp and
> get
> > > new results when clicked. I've set it up so the click() method
> > > correctly captures the scroll position, calls the jsp, and then
> > sets
> > > the scrollToIndex to the previous value of the scroll position.
> It
> > > works great while the "busy cursor" is displayed, but it reverts
> > > back to scrolled all the way at the top once the actual data
> comes
> > > in from the jsp (it takes about 3 seconds to update the grid
> with
> > > the new data).
> > >
> > > any ideas on where the scroll position is being reset?
> > >
> > > --- In [email protected]
> > <mailto:flexcoders%40yahoogroups.com> , "Deepa Subramaniam"
> > > <dsubrama@> wrote:
> > > >
> > > > Hi Jordan -
> > > >
> > > >
> > > >
> > > > You can keep track of the verticalScrollPosition property in
> your
> > > > DataGrid and upon receving UPDATES, re-set the
> > > verticalScrollPosition to
> > > > the previous value and the DataGrid will jump to the last
> scroll
> > > > position and show the correct content.
> > > >
> > > >
> > > >
> > > > -deepa
> > > >
> > > >
> > > >
> > > > ________________________________
> > > >
> > > > From: [email protected]
> > <mailto:flexcoders%40yahoogroups.com>
> > > [mailto:[email protected]
> > <mailto:flexcoders%40yahoogroups.com> ] On
> > > > Behalf Of Jordan Snyder
> > > > Sent: Monday, June 26, 2006 7:34 PM
> > > > To: [email protected] <mailto:flexcoders%
> 40yahoogroups.com>
> >
> > > > Subject: [flexcoders] Keeping DataGrid from scrolling to top
> on
> > > update
> > > > to dataProvider
> > > >
> > > >
> > > >
> > > > Hello All,
> > > >
> > > > I am working on an app in which I poll the server quite
> > frequently
> > > to
> > > > get new information. The information comes to me in an XML
> > format
> > > that
> > > > I simply assign as the dataProvider for a DataGrid component.
> > > >
> > > > I have to keep in consideration the fact that the user may
> have
> > > selected
> > > > a certain row, and may want to delete that row even after an
> > > update to
> > > > the dataProvider is made, so I keep track of the selectedIndex
> > > property
> > > > and reselect upon an update.
> > > >
> > > > But if the user has not selected a row, the DataGrid will
> > > automatically
> > > > scroll to the top upon an update, even if the user has
> scrolled
> > to
> > > the
> > > > bottom of the grid.
> > > >
> > > > Is there a way around this? I found a way to scrollToIndex(),
> > but
> > > no
> > > > way of getting the currently viewed items. It may have
> > something
> > > to do
> > > > with the various renderer properties available on the
> DataGrid,
> > > but I
> > > > have a very limited understanding of this, so it's over my
> head.
> > > >
> > > > Surely this problem has been run into before, but I can't seem
> > to
> > > find
> > > > the right combination of search terms to figure out a method
> of
> > > solving
> > > > it.
> > > >
> > > > Does anyone have any ideas or proven methods for the problem?
> > Any
> > > help
> > > > would be greatly appreciated.
> > > >
> > > > Thank you,
> > > >
> > > > Jordan Snyder
> > > > jordan.snyder@
> > > > www.jordansnyder.com
> > > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > --
> > > Flexcoders Mailing List
> > > FAQ:
> > http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> > <http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt>
> > > Search Archives:
> > > http://www.mail-archive.com/flexcoders%40yahoogroups.com
> > <http://www.mail-archive.com/flexcoders%40yahoogroups.com>
> > > Yahoo! Groups Links
> > >
> >
>

__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to