Hi Priyank,

Point 1 : You can't restrict the scroll bar size of DataGrid, because
it depends on number of rows available in DataGrid, if you still want
to implement that behavior extend the data grid class override scroll
bar updating code :).

Point 2 : Your problem is quite interesting, but the solution is
simple cache the scroll position as I did here :),

For running example http://imtiyaz.ms.googlepages.com/DataGridTest.html

Something like this.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
main.mxml
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
<?xml version="1.0"?>
<!-- dpcontrols/DataGridPassData.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
   initialize="initData()">
   <mx:Script>
   <![CDATA[
      import mx.collections.*;

      [Bindable]
      public var initDG:ArrayCollection;
      public function initData():void {
        var obj:Object;
        initDG = new ArrayCollection();
        for(var i:int =0;i<5;i++){
                obj = new Object();
                obj.BillNo = "Bill no  "+index;
                obj.Price = Math.random()*100;
                initDG.addItem(obj);
                index++;
        }

      }
      private var index:int = 0;
      private var scrollpos : Number = 0;
      public function addMoreBills():void{

        var obj:Object;
        scrollpos = myGrid.verticalScrollPosition;
                for(var i:int =0;i<5;i++){
                obj = new Object();
                obj.BillNo = "Bill no  "+index;
                obj.Price = Math.random()*100;
                initDG.addItem(obj);
                index++;
                }
    // uncomment to test the worst case behaviour (That is changing
the data provider, with the new data provider )
    //  myGrid.dataProvider = initDG;

        myGrid.verticalScrollPosition = scrollpos;
      }


   ]]>
   </mx:Script>

   <mx:DataGrid id="myGrid" width="350" height="200"
      dataProvider="{initDG}">
      <mx:columns>
         <mx:DataGridColumn dataField="BillNo" />
         <mx:DataGridColumn dataField="Price" />
      </mx:columns>
   </mx:DataGrid>
   <mx:Button label="Add More Bills" click="addMoreBills()"/>

</mx:Application>

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Hope this solution solves the things,

Regards,
Imtiyaz Basha M S,

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to