It cannot see the columns that are not rendered due to column virtualisation. The rendered rows are all the rows you can see on the screen through the vertical scroll plus a small buffer (default buffer size is 20).Īutosizing columns looks at the rendered cells on the screen, and works out the width based on what it sees. For example, if your grid has 10,000 rows, but only 50 rendered due to virtualisation of rows, then only these 50 will be considered for working out the width to display. The grid works out the best width by considering the virtually rendered rows only. Note the following with regards to autosizing columns: When you do this, the grid will work out the best width to fit the contents of the cells in the column. Just like Excel, each column can be 'auto resized' by double clicking the right side of the header rather than dragging it. The country column has maxWidth: 300, which takes precedence over the functions minWidth: 900 defined for the country column.The age column has maxWidth: 50, which takes precedence over the functions defaultMinWidth: 100.The athlete column has suppressSizeToFit and is not resized. In the following example, after clicking the button, note the following: These widths will not exceed the column's defined minimum and maximum widths.įor example assuming a grid with three Columns, the algorithm will be as follows:Īssuming the grid is 1,200 pixels wide and the Columns have default widths of 50, 120 and 300,ĪvailableWidth = 1,198 (available width is typically smaller as the grid typically has left and right borders) The function can receive a parameters object with minimum and maximum widths, either for all columns or for specific columns, to further restrain the column's resulting width from that function call. The result is deterministic and does not depend on any Column resizing the user may have manually done. Will still be twice the size of Column B, assuming no Column min-width or max-width constraints are violated.Ĭolumn default widths, rather than current widths, are used while calculating the new widths. If Column A has a default size twice as wide as Column B, then after calling api.sizeColumnsToFit() Column A The grid calculates new column widths while maintaining the ratio of the column default widths. This is helpful if, for example, you want the first column to remain fixed width, but all other columns to fill the width of the table. If you don't want a particular column to be included in the auto resize, then set the column definition suppressSizeToFit=true. The columns will scale (growing or shrinking) to fit the available width. columnDefs = Size Columns to FitĬall the Grid Api api.sizeColumnsToFit(params) to make the currently visible columns fit the screen. The snippet below allows all columns except Address to be resized by explicitly setting each column. To set resizing for each column, set resizable=true on the default column definition. Turn column resizing on for the grid by setting resizable=true for each column. All columns can be resized by dragging the top right portion of the column.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |