TreeGrid v6.0

Column width

TreeGrid documentation index

 

Every column can have set its width by Width otherwise its width is automatically calculated on start, but it can slow down the grid.

Every column’s width can be also automatically calculated to fill all the main tag, set it by RelWidth.

Columns can be resized by a user, by mouse dragging.

Space row cells are independent on columns and have set their Width attributes.

 

<C>                   int          Width                       Saved to cookies, avoid it by <C WidthLap=’1’/>                                                     .

Column width in pixels. It is outer width including all side buttons, cell border and padding.

If it is not set, it is automatically computed before the grid is first displayed according to the width of first few cells in the column.

If there any many columns, the automatic width calculation can slow down the rendering, so you should set Width for all or most of them!

If the cell content is wider than column width, it is overflowed in normal cells and wrapped in multiline cells (Type=Lines, Html, ...).

 

<C>                   int          RelWidth                                                                                                                                                   .

If set, the column width is automatically computed to fill all the remaining space in main tag.

The width is automatically recalculated whenever the width of the main tag or its content changes.

If there are more RelWidth columns in grid, their width is computed as ratio of their RelWidth values.

The RelWidth columns together fill the remaining vertical space in main tag, so the grid has always constant height of the main tag.

Using too many RelWidth columns can remarkably slow down grid usage!

You can set <Cfg ShowVScroll=’1’/> to always show vertical scrollbar to speed up grid, especially in tree.

You can set minimal width by MinWidth.

It is ignored when set <Cfg NoHScroll or MaxHScroll or NoScroll /> attribute.

If the RelWidth column is resized by a user, it looses its capability and gets fixed width. Back to relative width can be forced by resizing it to zero width.

 

<C>                   int          MinWidth                                                                                                                                                 .

Minimal width for width calculated on start (no Width set), for width calculated by RelWidth and for column resizing by a user.

If not set, minimal column width is cell border + padding.

If not set or set less than 20, resizing column by a user below the MinWidth sets the column to automatic width and calculates it according to its content.

 

<C>                   bool       OverflowEllipsis      Removed, set “text-overflow:ellipsis;” for G_Cell in Grid.css file.     

 

<C>                   int          GroupWidth                                                                                                                            upd 7.0 .

A width of column when it is set as main column to show tree when grid is grouped.

You can specify this width to change column width when it becomes main column while grouping – to resize column to accommodate the tree.

When grid is ungrouped or it shows the tree in another column, the column width returns to previous setting.

Since 7.0, if set to 1, the width of the column will be automatically increased by the widths of columns hidden by grouping.

 

<C>                   bool       CanResize          [1]                                                                                                                                 .

If column can be resized by a user by mouse dragging by column’s right edge. The column resizing must be also permitted globally by <Cfg ColResizing=’1’/>.

If set to 1, fixed column can also be resized automatically if there is no room for it, to preserve displaying “Too small extents” message.

 

<Cfg>                bool       ColResizing     [1]                                                                                                                                 .

All columns that have set <C CanResize=’1’/> can be resized by a user.

 

<C>                   int          VarHeight            [0]                                                                                                                   new 7.0 .

Set to columns containing wrap able cells, to shrink row height when the column is resized by a user and cells values occupy less height.

For 1 the rows are resized after column resizing finishes.

For 2 it resizes the rows during column resizing, it can be slow and should be used only for small grids.

 

<Space cell>    int          Width          [100]                                                                                                                                           .

Width of the Space cell in pixels. If not set, it has default value 100px. It is inner width without side buttons and border and cell padding.

It can be set to -1 to automatically calculate width according to cell content every time. If the cell value is changed, its width is updated.

It can be set to -2 to automatically calculate width according to cell content first time.

 

<Actions>                      ColResize                         Mouse dragging action, only for OnDrag... event                                         .

Starts resizing column by mouse. This actions resizes also right side Pager.

By default is the action attached to OnDragHeaderLeft (header left edge), OnDragHeaderRight (header right edge) and OnDragPagerHeaderRight (right side pager header right edge).

 

API event          void       OnColResize   (TGrid grid, string col)                                                                                                .

Called when column is resized, by a user or due RelWidth or by API call SetWidth.

It can be called more times during resizing column by a user, for every change.

 

API event          void       OnAfterColResize   (TGrid grid, string col)                                                                     new 6.3 .

Called after column or right pager is resized by a user. Called only once.

 

API method      void       SetWidth              (string col, int dx)                                                                                                        .

Changes column with about dx pixels. Displays the change in grid.

The dx can be positive (enlarge) or negative (shrink). The resulted column width will be grid.Cols[col].Width + dx.

If the resulted width will be less than MinWidth, the column width is automatically calculated according to its content or it restores RelWidth if it was set.

 

API method      void       CalcWidth          (string col, bool noupdate = 0)                                                                     upd 6.0 .

Computes column width according to the first 100 visible cells in this column, including all fixed cells and header.

In server paging if no rows are loaded yet it uses only fixed cells for calculation!

By default updates the column width in grid, if set noupdate = 1, it just sets the Width attribute.

This method is called on start for every column that has not set Width or RelWidth.