views:

662

answers:

2

look at this code (couldn't paste it here it doesn't fit)it represent my real app structure: mxml source code

EDIT: the relevant part of the code:

     <mx:VBox width="100%" height="100%">
      <mx:HBox width="100%" horizontalScrollPolicy="off" height="100%">  
        <mx:VBox width="100%" verticalScrollPolicy="off" height="100%">
          <mx:DataGrid height="100%" headerHeight="40" width="100%" wordWrap="true">

            <mx:columns>
              <mx:DataGridColumn dataField="serial_number" minWidth="60" 
                width="60" headerText="serial number"/>
              <mx:DataGridColumn dataField="int_number" minWidth="80"
                width="80"    headerText="int. number"/>
              <mx:DataGridColumn dataField="ext_number" minWidth="200"
                width="200"    headerText="ext. number"/>
              <mx:DataGridColumn dataField="desc" minWidth="200"
                headerText="description"/>
              <mx:DataGridColumn dataField="issued_by" minWidth="100"
                 width="100"    headerText="issued by"/>
              <mx:DataGridColumn dataField="contractual_date" minWidth="85"
                width="85"    headerText="contractual date" />
              <mx:DataGridColumn dataField="file_size" minWidth="60"   
                width="60"    headerText="file size"/>
              <mx:DataGridColumn dataField="n_sheets" minWidth="60"   
                width="60"    headerText="n. of sheets"/>
              <mx:DataGridColumn dataField="contains_drawing" minWidth="65"
                width="65"    headerText="contains drawing"/>
              <mx:DataGridColumn dataField="issue_at_shipment" minWidth="65"
                width="65"     headerText="issue at shipment"/>
              <mx:DataGridColumn dataField="rev_max_int_number" minWidth="65"
                width="65"      headerText="last rev"/>
            </mx:columns>

          </mx:DataGrid>
        </mx:VBox>
      </mx:HBox>
    </mx:VBox>

this is the compiled version you can view online: compiled swf

now.. resize a bit the window, look at how oddly the colums resize! The behaviour I'd like to obtain is to have all columns fixed except for the description column, for which I haven't speified the width but only the minWidth property.

thanks

A: 

I would say to bind the width to the value that you want, that way it wont resize:

var mySize:int = 60;
<mx:DataGridColumn width="{mySize}" />

Let me know, thanks!

Luis B
maxWidth doesn't exist..the other solution is equivalent to assigning it directly unless I somehow dispatch the mySize var every few millisecs.. and that's not nice!
luca
well, mySize is binded to the datagridcolumn's width .. so wouldnt it always be looking to mySize to see and emulate its value?
Luis B
A: 

Just a note for future searches: setting minWidth on columns added after the (3.5b SDK) DataGrid is added to a display list (aka dynamically added columns) can put the entire grid in a very bad state where the horizontal scroll bar thumb is inaccurately reflecting a wider grid than actually exists.

If one adds columns by pushing column objects (that have .minWidth set) to an array and assigning that array to DataGrid.columns, the grid acts like it thinks it is wider than it really is:

  • it draws itself as wide as possible (ignoring any .right or .width values)
  • its horizontal scroll bar thumb is wider than the visible width would indicate
  • one cannot scroll to make the right-most columns visible
  • what scrolling one can do is very slow

The solution is: don't do that (use the .minWidth property, that is).

Cheers

Richard Haven