0 Replies Latest reply on Nov 26, 2009 9:47 PM by Pratap Reddy

    Problem with datagrid horizontal scrollbar

    Pratap Reddy

      Hi all,

       

      I am facing problem with Datagrid HorizontalScrollBar.

       

      As per requirement i need to seperate the Horizontal and verticalscroll bars from grid.
      So what i did was, i created HScroll & VScroll components and associated them Datagrid scroll bars. I made HorizontalScrollPolicy and VerticalScrollPolicy "off" for datagrid.

       

      As i binded values to HScroll & VScroll components which are out side of datagrid, i should be able to scroll datagrid using those components.
      Its working fine for VScroll. When i scroll VScroll component am able to scroll datagrid vertically.

       

      Problem is with HorizontalScrollPolicy in datagrid, when i change the policy to "on" i can see the scrollbar down to datagrid and able to scroll.  once i change the policy to "off", datagrid columns are getting resized and datagrid width will set back to its container width without scrollbar, because of this there will be no HorizontalBar for datagrid to assiciate with HSCroll Component.

       

      Code given below:

       

      [AS]
      private function vScrollGrid(event:ScrollEvent):void
      {   
        mainTable.verticalScrollPosition=vScrollBar.scrollPosition;
      }

       

      private function hScrollGrid(event:ScrollEvent):void
      {   
        mainTable.horizontalScrollPosition=hScrollBar.scrollPosition;
      }[/AS]

       

      [CODE]
      <mx:HBox height="100%" verticalScrollPolicy="off"  horizontalScrollPolicy="off">
              <mx:DataGrid dataProvider="{reportData}"
                   id="mainTable"   
                   height="100%"
                   width="100%"
                   textAlign="right" allowMultipleSelection="true" visible="false" verticalScrollPolicy="off" horizontalScrollPolicy="off"/>
              <mx:VScrollBar id="vScrollBar" height="100%" pageSize="1" scrollPosition="{mainTable.verticalScrollPosition}" maxScrollPosition="{mainTable.maxVerticalScrollPosition}" scroll="vScrollGrid(event)"/>

       

      </mx:HBox>
      <mx:HScrollBar id="hScrollBar" height="100%" pageSize="1" scrollPosition="{mainTable.horizontalScrollPosition}" maxScrollPosition="{mainTable.maxHorizontalScrollPosition}" scroll="hScrollGrid(event)"/>
      [/CODE]

       

      Please help me to resolve this

       

      Thanks & Regards
      Pratap