Column width
TreeGrid documentation
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
<fg 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.
For successful printing set
PrintWidth for the relative width column.
new 11.0 upd 12.0 <C> int
RelWidthType
[0]
Changes
RelWidth behavior. Bit array.
1. bit | &1 | 0 - Resizes the column to fill the main tag (the whole grid) |
| | 1 - Resizes the column to fill its column section, the LeftWidth / MidWidth / RightWidth. |
2. bit | &2 | (new 12.0) If set with 1.bit, it shrinks the column until the column section hides its scrollbar. |
3. bit | &4 | (new 12.0) If set with 1.bit, it never hides column with MinWidth. If not set, it hides the column if it would be narrower than MinWidth. |
4. bit | &8 | (new 12.0) If set with 1.bit, it also resizes the column to fill the main tag (the whole grid) width. |
new 12.0 <C> bool
ConstWidth
[0]
Empty relative width column. Useful to automatically maximize column section (with
RelWidthType='1') or the whole grid (with
RelWidthType='0').
By default it is created by
<Cfg ConstWidth/>.
It is completely inactive, with special empty CSS class.
<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.
new 13.2 <C> int
MaxWidth
Maximal width for width calculated on start (no Width set), for width calculated by
RelWidth and for column resizing by a user.
<C> bool
OverflowEllipsis
Removed, used "text-overflow:ellipsis;" in ...Grid.css file.
upd 7.0 <C> int
GroupWidth
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.
new 13.0 <Cfg> int
Overlay
[0]
Permits using column attribute
Overlay to overlay empty cells like in MS Excel.
If set to
2 it also updates cell borders of the overlaid cells.
Value 2 can slow down the grid!
new 13.0 <C> int
Overlay
[0]
If the cell value can overlay next cells and if previous cell value can overlay this cell. Bit array.
Used only if set <Cfg Overlay>
1. bit &
1 - If the cell value can overlay next cells if it is wider than the cell width.
2. bit &
2 - If previous cell will not overlay this cell if it has some value.
3. bit &
4 - If set with 2.bit, the cell will not be overlaid either if it has empty value.
Standard value for MS Excel like behavior is
3.
It never overlays: cells with side buttons, main column, cells between column sections, header and filter rows. In Chrome it does not overlay cells between column pages.
The cells overlaying next cells are ignored when calculating column width automatically.
new 12.1 <C> int
Overflow
[0]
Use to speed up large grids with many cells on WebKit browsers (Chrome, Safari, Opera).
There is a bug in WebKit engine that causes the more tags with overflow:hidden is on page, the slower is every re-flow action on page.
You can define Overflow for all columns that are enough wide to show all theit content, so they don't need to overflow their cells content.
0 - Hidden, sets overflow:hidden to all column cells except empty. Standard, but slow.
1 - Visible, sets overflow:visible to all column cells. Fast, but the wider cell value overflows to next cell(s).
number - sets overflow:hidden to all cells if the column has Width < number or sets overflow:visible to all cells if the column has Width > number.
It does
not affect Header and Filter rows, they always use overflow:hidden.
<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.
new 11.0 <C> <cell> int
Resizing
[0/2]
If the cell checks its edges for mouse actions, bit array.
Default value is
2 for Header rows and
0 for other rows.
0 - no edge
1 - top and bottom edge for row resizing, event target is HeaderTop and HeaderBottom
2 - left and right edge for column resizing, event target is HeaderLeft and HeaderRight
3 - both vertical and horizontal edges.
new 7.0 <C> int
VarHeight
[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.
This attribute also affect printing, see
VarHeight.
new 10.0 <C> int
MaxCalcWidth
[100]
Maximal count of rows to iterate when calculating column width.
Increasing the value can slow down the action.
<Space cell> int
Width
[100/-1]
Width of the Space cell in pixels. If not set, it has default value 100 and for Button and Label has -1. 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.
new 13.0 <Space cell> int
MinWidth
Minimal width of the cell for
Width = -1 or -2. In pixels.
new 13.0 <Space cell> int
MaxWidth
Maximal width of the cell for
Width = -1 or -2. In pixels.
new 13.0 <Space cell> int
MinEditWidth
[10]
Minimal width of the tab cell if edited. In pixels. Usually used for renaming sheet.
<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.
new 6.3 upd 9.2 API event void
OnAfterColResize
(TGrid grid, string col, TRow row, int chg)
Called after column or right pager is resized by a user. Called only once.
(Since 9.2) row is the header row where the column edge was dragged.
(Since 9.2) chg is change of width in pixels.
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.
upd 13.2 API method void
CalcWidth
(string col, bool noupdate = 0, TRow[] rows = null)
Computes column width according to the first 100 (set by
MaxCalcWidth) 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!
Since 13.2 if set
rows it checks all these rows instead of the first 100. The
rows array can be got by
GetShownRows to check actually visible rows.
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.
new 10.0 API method int
TestCellWidth
(TRow row, string col = 0)
If the cell shows its content fully.
Works only for already rendered cell.
Returns required change of the column width to show the whole cell content. Returns only 0 or positive value.