I ran the test case.  I see it jump, and it should if you're sorted on
the column.  We do try to keep the selected item in view.  I think I saw
it not keep it in view once or twice so that might still be a bug, but
would expect jumping if the sorted column data is being changed.
 
We hit the lower-level scrollposition so that's why your handler didn't
get called.
 
One way to block it might be to subclass, overrride
collectionChangeHandler, and on REFRESH, set anchorBookmark to null
before calling super and restore it afterwards.
 
-Alex

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Daniel Grace
Sent: Thursday, April 05, 2007 3:32 PM
To: [email protected]
Subject: Re: [flexcoders] DataGrid Jumping



After more fully evaluating the problem, the simple test case that I
wrote DOES exhibit the behavior when I follow all requisite steps:

1) Load the flash
2) Sort by the only field

The sorting appears to be necessary. It seems to me, from watching, that
when the first row moves off of the screen, the viewport moves to keep
the old first row to be the first row in the viewport. After that, that
particular row is no longer followed, but it will jump subsequent times,
perhaps to try and follow the new first-row, when it moves away from
being the first row? Either way, with sorting on this example using all
native Flex components jumps around like crazy. 

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> " layout="absolute"
applicationComplete="appComplete();"> 
    <mx:DataGrid dataProvider="{ac}" width="100%" height="100%">
        <mx:columns>
            <mx:DataGridColumn headerText="Testing" dataField="timer" />

        </mx:columns>
    </mx:DataGrid>
    <mx:Script>
        <![CDATA[
            import mx.utils.ObjectProxy;
            import mx.collections.ArrayCollection;
            import flash.utils.Timer;
            import mx.core.Application;
            
            public var t: Timer = new Timer(1000);
            [Bindable]
            public var ac: ArrayCollection = new ArrayCollection([ 
                new ObjectProxy({'name': 'Test 1', 'timer': 0}),
                new ObjectProxy({'name': 'Test 1', 'timer': 0}),
                new ObjectProxy({'name': 'Test 1', 'timer': 0}), 
                new ObjectProxy({'name': 'Test 1', 'timer': 0}),
                new ObjectProxy({'name': 'Test 1', 'timer': 0}),
// Repeat enough times to make this take up more than one screen... or
just shrink your window 
                new ObjectProxy({'name': 'Test 1', 'timer': 0}),
                new ObjectProxy({'name': 'Test 1', 'timer': 0})]);

        private function appComplete(): void { 
            this.t.addEventListener("timer", this.doTick);
            this.t.start();
        }
        
        private function doTick(e: Event): void {
            for (var i: Number = 0; i <
Application.application.ac.length; i++) {
                Application.application.ac.getItemAt(i).timer +=
(Math.random() * 10) - 5;
            }
        }
        ]]>
    </mx:Script>
</mx:Application> 

Daniel


On 4/5/07, Daniel Grace <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> > wrote: 

        Just to repay the quick reply to my email, you should know that
a very quck test case failed to replicate the bug without the rest of my
framework involved. I have also noticed a few more things about this
bug. First, it only happens if I have a sorted field (I don't do any
custom sorting, and it happens at least with String sorting, which is
the most common field anyone sorts on in this application) and it mostly
happens when the text I am sorting on has changed somewhere
(unfortunately, that's common enough that I can't be sure that's part of
the true cause). I don't have lines selected at the time. I created a
function to try and find the bug (in a DataGrid subclass): 
        
                    public function set veriticalScrollPosition(n:
Number): void {
                        Application.application.logError("Setting scroll
position to " + n);
                        super.verticalScrollPosition = n;
                    }
        
        Note that this failed to ever run, even when I saw the bug
happen. Are there any other functions that could trap when this bug is
rearing its head? I like having the source to most/all of the framework
for when something like this happens, but there sure is a lot of code to
try and understand. 
        
        Daniel 
        
        
        
        On 4/5/07, Alex Harui < [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> > wrote: 

                I don't remember any bugs like that.  Can you build a
small test case that uses regular DataGrid?

________________________________

                From: [email protected]
<mailto:[email protected]>  [mailto:[email protected]
<mailto:[email protected]> ] On Behalf Of Daniel Grace
                Sent: Thursday, April 05, 2007 12:40 PM
                To: [email protected]
<mailto:[email protected]> 
                Subject: [flexcoders] DataGrid Jumping
                
                
                

                I am using a DataGrid that is mostly stock (overrode
drawRowBackground
                and set dataProvider. This particular datagrid has a lot
of
                information in it that changes every second. That's all
fine.
                
                If there is a vertical scroll bar (common) and I am
scrolled to the
                top, with no rows selected, it will periodically jump
down to what
                appears to be roughly the halfway point. This seems to
happen when
                something changes (and happened a lot less frequently
before I put the
                timers in). There is a chance that I have messed
something up, but I
                doubt it. I know that it happened before I overrode set
dataProvider.
                
                My real question is -- is this addressed in the hotfix?
I don't see
                specific mentioning of it on
        
http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=kb401224
<http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=kb401224> ,
                though there are fixes in the datagrid. After seeing a
few problem
                reports here I'm not overly eager to install the hotfix
if it is not
                going to fix a problem that I am having (also, the page
referenced
                suggests this strategy).
                
                Or, does anyone know what might be causing my scroll
position to jump,
                without overriding any functions that would logically
cause such a
                behavior?
                
                Daniel
                

                



 

Reply via email to