7 Replies Latest reply on Dec 7, 2010 12:10 PM by Flex harUI

    Datagrid and verticalScrollPosition

    aciam70
      Hello everyone

       

      I have a datagrid with an editable column.

      When I enter in an editable cell, automatically a new position of vertical scroll bar is set.

      Why?

      How can I prevent it?

       

      Thanks
        • 1. Re: Datagrid and verticalScrollPosition
          Flex harUI Adobe Employee

          Are you editing the last row?  Or a row that is taller than the visible

          area?  Otherwise it shouldn't shift.

          • 2. Re: Datagrid and verticalScrollPosition
            aciam70 Level 1

            Hi, thanks for your kind answer, but  my  problem is: every row that I'm editing, it automatically get up, and take the  first visible position in the data grid.
            Of course it happens when there are many other visible rows
            How can I set the row always at the same position?

            Thanks

            • 3. Re: Datagrid and verticalScrollPosition
              saisri2k2 Level 4

              Yup, Ive seen this behaviour in the list as well, when I use checkbox as a custom itemrenderer, and the user clicks the checkbox, the list will scroll automatically, is it because the list height is small?? i have only 3 rows being shown.

              • 4. Re: Datagrid and verticalScrollPosition
                Flex harUI Adobe Employee

                Do you have a custom editor?  Try a simple example with the default editor

                and see if you have the same problem.

                • 5. Re: Datagrid and verticalScrollPosition
                  Flex harUI Adobe Employee

                  If you have a small example, post it.

                  • 6. Re: Datagrid and verticalScrollPosition
                    aciam70 Level 1

                    Here my example:

                     

                     

                    <?xml version="1.0" encoding="utf-8"?>
                    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                                   xmlns:s="library://ns.adobe.com/flex/spark"
                                   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
                        <fx:Declarations>
                            <!-- Place non-visual elements (e.g., services, value objects) here -->
                        </fx:Declarations>
                        <fx:Script>
                            <![CDATA[
                                import mx.collections.ArrayCollection;
                                import mx.events.DataGridEvent;
                                import mx.events.ListEvent;
                               
                                private var gacSorting:ArrayCollection  = new ArrayCollection([
                                    {OrigID:"0", OrigCutoff:"", Deadline:"00:00", Editing:"0"},
                                    {OrigID:"1", OrigCutoff:"00:00", Deadline:"", Editing:"0"},
                                    {OrigID:"2", OrigCutoff:"01:00", Deadline:"", Editing:"0"},
                                    {OrigID:"3", OrigCutoff:"02:00", Deadline:"", Editing:"0"},
                                    {OrigID:"4", OrigCutoff:"03:00", Deadline:"", Editing:"0"},
                                    {OrigID:"5", OrigCutoff:"04:00", Deadline:"", Editing:"0"},
                                    {OrigID:"0", OrigCutoff:"", Deadline:"00:00", Editing:"0"},
                                    {OrigID:"1", OrigCutoff:"00:00", Deadline:"", Editing:"0"},
                                    {OrigID:"2", OrigCutoff:"01:00", Deadline:"", Editing:"0"},
                                    {OrigID:"3", OrigCutoff:"02:00", Deadline:"", Editing:"0"},
                                    {OrigID:"4", OrigCutoff:"03:00", Deadline:"", Editing:"0"},
                                    {OrigID:"5", OrigCutoff:"04:00", Deadline:"", Editing:"0"}]);
                                           
                               
                                protected function SortingChangeHandler(event:ListEvent):void
                                {
                                    if(gacSorting[event.rowIndex].OrigID == "0")
                                    {
                                        dgcDeadlineSort.editable = true;
                                        dgcOrigCutoffSort.editable = false;
                                    }
                                    else
                                    {
                                        dgcDeadlineSort.editable = false;
                                        dgcOrigCutoffSort.editable = true;
                                    }
                                }
                               
                                protected function ItemEditBeginningHandler(event:DataGridEvent):void
                                {
                                    gacSorting[event.rowIndex].Editing = 1;
                                    gacSorting.refresh();

                                }
                            ]]>
                        </fx:Script>
                       
                        <mx:DataGrid id="dgSorting" width="90%" height="24%"
                                     selectable="true" allowMultipleSelection="false"
                                     dataProvider="{gacSorting}" editable="true"
                                     change="SortingChangeHandler(event)"
                                     itemEditBeginning="ItemEditBeginningHandler(event)">
                            <mx:columns>
                                <mx:DataGridColumn id="dgcOrigID" dataField="OrigID" textAlign="center" editable="false" headerText="Orig ID"/>
                                <mx:DataGridColumn id="dgcOrigCutoffSort" dataField="OrigCutoff" textAlign="center" editable="true" headerText="Cut off"/>
                                <mx:DataGridColumn id="dgcDeadlineSort" dataField="Deadline" textAlign="center" editable="true" headerText="Deadline"/>
                            </mx:columns>
                        </mx:DataGrid>
                    </s:Application>

                     

                     

                     

                     

                     

                    If I comment "gacSorting.refresh();" inside itemEditBeginning, it works correctly.

                    Why?

                     

                    Thanks

                    • 7. Re: Datagrid and verticalScrollPosition
                      Flex harUI Adobe Employee

                      I didn't have time to run your test case, but it looks like you are changing

                      the data as the editor comes up.  That might cause your problem.