views:

217

answers:

2

look at this code:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" horizontalScrollPolicy="off">
    <mx:VBox horizontalScrollPolicy="on" width="100%">
     <mx:DataGrid>
      <mx:columns>
       <mx:DataGridColumn width="5000" />

      </mx:columns>
     </mx:DataGrid>
    </mx:VBox>
</mx:Application>

The datagrid is outside the limits of my screen, but the scrollbar is useless.. To show you what I mean, look at the compiled output here: http://dl.dropbox.com/u/1663633/prova.swf

Any Idea? Of course this is a simple example, my real life file is much more complex and the scrollbar MUST be just around the dataGrid, not on the whole application.

+1  A: 

The problem is the VBox is bigger than the Application, even when you set width="100%". It's not clear to me why it (mis)behaves like that, but you can force it to be the same size as the Application by using width="{width}" on the VBox.

Wouter Coekaerts
No, same thing happen with layout set to vertical or horizontal..Besides, application.width doesn't get compiled "Access of undefined property application." ??
luca
You're right, it doesn't seem to be because of the absolute layout.And I meant "Application.application.width", or just "width" in this case.Anyways, the workaround of setting the width explicitly seems to work. (Edited the answer.)
Wouter Coekaerts
A: 

The layout engine for the datagrid is not able to handle a column wider than the datagrid itself. You will not have this problem with columns smaller than the datagrid.

For example, if the datagrid is 500 pixels wide and you have multiple columns of 250 pixels, you can get the scrolling policy you were looking for like this:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" width="500" layout="absolute" horizontalScrollPolicy="off">
    <mx:VBox >
        <mx:DataGrid width="500" horizontalScrollPolicy="on" >
            <mx:columns>
                    <mx:DataGridColumn headerText="a" width="250" />
                    <mx:DataGridColumn headerText="b" width="250" />
                    <mx:DataGridColumn headerText="c" width="250" />
                    <mx:DataGridColumn headerText="d" width="250" />
                    <mx:DataGridColumn headerText="e" width="250" />
                    <mx:DataGridColumn headerText="f" width="250" />

            </mx:columns>
        </mx:DataGrid>
    </mx:VBox>
</mx:Application>

This will work even if the total width of the columns is larger than the datagrid.

Jean-Philippe Goulet
NO! You set a width to the dataGrid!! That's the whole point, it must remain 100% width. If you set a with on my example it works. The thing about multiple columns vs one big one doesn't seem to make any difference in itself.
luca
same thing goes for the application.. width="100%"
luca
I put 500px width in order to force a scroll bar because I work on a 1920px wide display. Just change it to 100% and it will work for your specific case. It doesn't change the fact that the datagrid min width should be at least as big as the biggest column. Maybe the datagrid is not what you are looking for. You might want to use a tile control.
Jean-Philippe Goulet
By the way, if you change to 100%, add a width="100%" to the vbox as well.
Jean-Philippe Goulet