Fixing a datagrid width with dynamic columns

apache-flex

I have a datagrid contained in a vbox, this datagrid acts as a spreadsheet it contains 70 columns, initially 10 are visible and the rest are hidden and the user selects which other colums to show dynamically.
I need this datagrid to use the maximum screen width available, so I have set the application's width to 100% as well as the vbox and the datagrid, I also set the horizontalscrollpolicy of the datagrid to "auto" so as that the more the columns the user selects he can use the grid's horizontal scroll bar to view the rest of the added columns. This ofcourse will vary according to the size of the monitor if the user has a huge one he won't have a very long scroll bar like users with small or medium sized monitors.

The problem is the more the columns I show, the datagrid reszies itself causing the application's horizontal scroll bar to appear leaving me with 2 adjacent horizonal scroll bars the one of the datagrid and below it the one of the application. This is both confusing and irritating for the user, now I have to use both scrollbars to see the new columns added plus other controls above the datagrid are not completely visible, I have to scroll the application's bar to the right to see them.

I don't understand, why does the datagrid stretches itself after a certain number of columns. Testing it at a resoluion of 1280×800 initially when the datagrid is with 10 columns and I start showing the other columns the datagrid's horizontal scroll bar automatically show's and it keeps getting longer while am adding more columns once i reach the column number 50 the datagrid stretches itself and the application's horizontal scroll bar appears (the number 50 will be different ofcourse with another resolution).

How can I stop this behavior? I only want the datagrid to fill the maximum screen width available and when there are more columns then there will only be the datagrid's horizontal scroll bar to use for scrolling left & right through the grid only and not the whole application.

Thanks in advance

Best Answer

I found 2 solutions either set the datagrid's property minColumnWidth to a small value like 5 for example and this will fix the width of the datagrid and prevent the application's scrollbar from showing or you can use this solution found here

Related Topic