7 Replies Latest reply on Aug 11, 2010 7:21 PM by PhilBailey

    My datagrid refuses to scroll (newbie)

    PhilBailey Level 1

      While working on a AIR project, I have created a several datagrids which will not scroll vertically. When the dataprovider is a hard-coded array, they work, but then when I bind to an array that results from a SQLLite SELECT statement, the data is displayed just fine, but the datagrid won't scroll beyond the visible rows.

       

      When I drag the scrollbar handle down, it pops back up to the top as soon as I release the mouse button. If I hold the mouse button down on the bottom scroll bar arrow, it flickers (it scrolls down a row and pops back up to the top within a few milliseconds). If I position the mouse pointer inside the list and flick the mouse scroll wheel very quickly, it will scroll down a few rows. As soon as I move the mouse pointer over the scroll bar, the list goes back to the top again.

       

      Has anybody seen this kind of behavior before?

       

      Code for datagrid and the panel that contains it:

       

       

      <s:Panel x="483" y="372"

           width="

      200" height="238"

           title="

      Commonly Used Buyer(s)"

           fontSize="

      14">

       

       

       

           <mx:DataGrid x="10" y="15"

                dataProvider="

      {buyerCollection}"

                fontSize="

      12" fontWeight="bold"

                width="

      178" height="100">

       

       

                <mx:columns>

       

       

                     <mx:DataGridColumn headerText="Buyer Name" dataField="BUYE_NAME"/>

       

       

                </mx:columns>

       

       

           </mx:DataGrid>

       

       

       

      </s:Panel>

        • 1. Re: My datagrid refuses to scroll (newbie)
          wise_qwerty
          verticalScrollPolicyproperty
          verticalScrollPolicy:String

           

          A property that indicates whether the vertical scroll bar is always on, always off, or automatically changes based on the parameters passed to the setScrollBarProperties() method. Allowed values are ScrollPolicy.ON, ScrollPolicy.OFF, and ScrollPolicy.AUTO. MXML values can be "on", "off", and "auto".

          Setting this property to ScrollPolicy.OFF for ListBase subclasses does not affect the verticalScrollPosition property; you can still scroll the contents programmatically.

           

          http://livedocs.adobe.com/flex/3/langref/mx/core/ScrollControlBase.html#verticalScrollPoli cy

          • 2. Re: My datagrid refuses to scroll (newbie)
            Ansury Level 3

            But he's not doing that anywhere in his code. Also the behavior he's describing isn't at all what happens when you disable scrolling.  The symptoms described are definitely unusual..

             

            Although, I'd be curious to know what happens if you try setting the scroll bar policy to "on" (or "off").  (verticalScrollPolicy="on")  What version of the SDK is this running on?

            • 3. Re: My datagrid refuses to scroll (newbie)
              Flex harUI Adobe Employee

              See if there are collectionChange events firing as you scroll.  If there are

              because data is paging in, that might mess up scrolling.

              • 4. Re: My datagrid refuses to scroll (newbie)
                PhilBailey Level 1

                I did try setting the verticalScrollPolicy to "off". It removed the scroll bar and prevented any scrolling as expected. I then tried the "on" and "auto" settings. In both cases, the same symptoms occurred.

                 

                Please forgive the newbie question but, how do I determine the SDK version? Are you referring to the AIR SDK? I am still using a trial version of Flex 4 that I downloaded about 21 days ago and I installed AIR at the same time.

                • 5. Re: My datagrid refuses to scroll (newbie)
                  PhilBailey Level 1

                  Sorry about my newbie status, but how would I check for the collectionChange event firing?

                  • 6. Re: My datagrid refuses to scroll (newbie)
                    jeffcg2 Level 1

                    Sounds like something in your script block is re-fireing your query. As a guess I would say you have the multiple calls to the same token. If you see duplicates you might comment out one to see what happens. Or post your script block. Maybe someone will see the problem.

                     

                    <fx:Script>
                            <![CDATA[
                                import mx.controls.Alert;
                                import mx.events.FlexEvent;
                                import mx.rpc.events.ResultEvent;
                               
                                import spark.events.IndexChangeEvent;
                               
                                protected function adg1_creationCompleteHandler(event:FlexEvent):void
                                {
                                    getAllTABLEResult.token =tABLESService.getAllTABLE();
                                }

                     

                                protected function getAllTABLESResult_resultHandler(event:ResultEvent):void
                                {
                                   getAllTABLEResult.token =tABLESService.getAllTABLE();
                                }

                     

                            ]]>
                        </fx:Script>

                    • 7. Re: My datagrid refuses to scroll (newbie)
                      PhilBailey Level 1

                      I figured it out!

                       

                      The problem was caused by me calling the data retrieval functions from the render event of a component. I did this because the component is only visible when the user switches to a certain application state. The component contains many datagrids and other bound controls, so I didn't want to retrieve data into its controls unless the user chose to switch to that state. Unfortunately, it seems that the render event fires over and over again. In fact, I suspect that it re-fired whenever data was displayed in the controls, so an endless loop was occurring.

                       

                      I have moved the retrieval logic to the application itself. This solved my datagrid scrolling problem. Unfortunately, this adds overhead and prevents me from achieving my original goal of loading the data only when the state is changed.

                       

                      If anyone has a suggestion for a good way to load data on state change, I would be interested. I suppose that I could put back it on the render event and set a "dataLoaded" flag variable to true after loading. On the render event, I would only load the data if the variable was false. I'm sure there's a better event or technique out there.

                       

                      Many thanks to all those who responded. The suggestions that an event was firing repeatedly certainly pointed me in the right direction!