3 Replies Latest reply on Feb 18, 2010 10:21 AM by Flex harUI

    Data Grid Column Width

    skider Level 1

      I've found through experimentation that if you specify a total width for a set of data grid columns that is greater than the width available in the grid, the data grid will interperet those widths in a ratio to their sum, and give each column a corresponding width. This is generally extremely helpful, as it means that columns tend to resize sensibly when adding or subtracting them, or when resizing the grid.

       

      However, it also causes a bit of a problem. We have one column that needs to stay the same pixel width all the time, no matter what other columns are present, or what size the grid is. So far, I haven't found a way to do this.

       

      Has anyone else encountered this problem? If so, how did you solve it?

        • 1. Re: Data Grid Column Width
          Flex harUI Adobe Employee

          As long as there is room for the other columns to shrink, resizable=false

          should lock the width of the one column.

          1 person found this helpful
          • 2. Re: Data Grid Column Width
            skider Level 1

            This seems to keep the initial ((column's declared width / total declared width of all columns) * data grid width) no matter what you do to the data grid afterwards, but the initial column width is variable according to the initial width of the data grid and the initial sum of the declared widths of the columns. Because of this, if you're using multiple data grids on the same page which are different widths to begin with, a column which has the same width set is a different size in each of them.

             

            I've attached a screenshot to show what I mean (with data removed). In this screenshot, the width of all three + columns is identical, and all three of them have resizable set to false. The sum of the widths of the columns in the top left and bottom grids are identical. The size of the + column varies between the grids, which I would assume is because the grids have different initial widths.

             

            Is there any way to specify the width absolutely (without going through the above formula) in the case that the sum of the column widths is greater than the width of the data grid? I get the feeling that there might not be, at least not without reprogramming DataGrid (or one of its associated classes).

             

            EDIT: I'm going to have to withdraw this question. I set the horizontalScrollPolicy to "on" to test whether the sizing was basically correct, and have gotten behavior so weird that there seems to be some kind of major sizing bug, either in my code (probably more likely) or in the Flex library. I'll mark this answered for now, since there are clearly other problems than just the initial sizing, as I had previously assumed, and even if the previous answer was right, I wouldn't be able to recognize it.

            • 3. Re: Data Grid Column Width
              Flex harUI Adobe Employee

              Columns default to having minWidth=50, I think.  In theory, if

              resizable=false on a column it will have its size honored if it is greater

              than its minWidth and there is enough room left for all other columns to

              shrink to their minWidths and still fit.  Only if there isn't enough room to

              fit non-resizable columns plus the minWidths of resizable columns do we

              start shaving everybody.  Or maybe there's a bug in that algorithm.