Column basics

TreeGrid documentation

TreeGrid column is defined by tag <C>, placed in <Cols> or <LeftCols> or <RightCols> section.
The column specifies position, size, visibility settings and restrictions of the grid column.
And also specifies default type, formatting, editability and other cell setting for all cells in the column. The type, formatting and other settings can be overridden for every particular cell by its attributes.
Columns do not contain cell values, the cells are defined in rows.
Column captions are defined in Header row(s).

TreeGrid column can be fixed (frozen) or variable (scrollable).

Fixed (frozen) column can be positioned on the left or on the right grid side. The fixed column cannot be scrolled outside view.
To set fixed column, place the <C> tag to <LeftCols> or <RightCols> section.
If all fixed columns together are too wide, wider then main tag width, TreeGrid can neither scroll them nor display them, so it cannot display its content and displays only message "Too small extents".

Variable (scrollable) column is positioned between left and right fixed section.
To set variable column, place the <C> tag to <Cols> section.
If all variable columns are wider then the variable section, they are horizontally scrolled.
A user can move the column between section (freeze / unfreeze) by mouse dragging if the column have set CanMove='2' (it is set by default).

To predefine some attributes for more columns define <D> tag with these attributes and place it to <DefCols> section. And point the specified columns to it by their Def attribute.
To predefine some attributes for all columns, set them to <D Name='C'> tag. This tag is placed also to <DefCols> section. By default it is defined in Defaults.xml with default settings for all grids.
For example if you define <Def><D Name='C' Type='Int'/></Def> all columns will have Type Int.

There is one special column, the row's left panel with buttons for deleting and selecting row. It is positioned as the first left fixed column and can be visible or hidden. It can be set by <Panel> attribute placed in root <Grid> tag.

In tree there is one main column where is displayed tree with icons for expanding and collapsing. In grid there can be only one main column, its name is set by <Cfg MainCol> attribute.

Column caption and other header setting are set by <Header> tag placed in root <Grid> tag.
<C> string

Name

Column name. Required. Every column must have set this attribute.
The Name identifies column and row's cells. Under this name are row's cells in this column set and accessed.
All column names must be unique among all column names inside one grid.
Under this name grid saves column configuration to the cookies.
In JavaScript API, cell is accessed by column name.
Column names are used also in formulas.
! Attention !
Column names are case sensitive.
Column names can contain only letters (a-z, A-Z), underscore '_' and digits (0-9), but cannot start with digit and should not start with underscore.
Column names must not interfere with row's attribute names, like Def, Kind or Deleted !
The best way is to name columns as letter 'A', 'B' or 'a', 'b'. There is no interference and data length is short.
For grids with many columns and saved configuration to cookies the column names should be less then 4 characters long, to shorten cookie length.
<Header cell> string

value

Column caption is not set in <C> tag, but in <Header> row cell.
The <Header> row is fixed (Head or Foot) row with column captions and sorting icons. It cannot be editable.
It has the same row and cell attributes like normal grid row, but it have usually different look (according to style definition).
You can especially use Header style attribute like Align, Wrap or NoEscape to format the column captions.
You can have more Header rows in grid. You can also span the Header cells to show merged column captions.
new 12.0 <I> bool

ShowColNames

[0/1]
If the fixed row cells show column names. By default it is set to 1 for Header rows and 0 for all others.
<C> string

MenuName

Html string displayed in Columns menu for this column. If not set, the column caption is displayed.
<C> string []

SearchNames

Comma separated strings as possible names of the column. Used for search and editable formulas.
new 6.0 upd 10.0 <C> <D> string

Def

["C"]
The name of default column <D> used for this column or default column. From this default the column inherits all its not set attribute values.
Remember, opposite to default rows all the columns read their values from default columns on start! So the default columns are not accessible by API.
Default value for Gantt type column is "Gantt", for other columns "C".
Since 10.0. It can contain more default names, comma separated. Remember the difference, <I Def/> can contain only one default.
upd 6.0 <D> string

Name

Name of default column. Required. This name is referenced by column attribute Def.
The <D> tag as default column can be placed only to <DefCols> section.
Any custom name can be used for default row.
There is one predefined name "C" as default column for all columns in grid.

Column index

Shows row with column positions, usually as number from 1 or alphabetical name.
It does not identify column uniquely, for column identification use column Name instead.
Used also for editable formulas. See also row index.
new 12.0 <Cfg> string

ColIndex

An id of the row that will show the column positions in grid.
If the row does not exist, it is created as the last row in Head section as <Header Def="Header" id=ColIndex Visible="1" Kind="Header"/>.
It is possible to set SearchNames to the same value as ColIndex to use the col index as column name.
I does not work in server paging.
It iterates all the ColIndex cells after any column order change and resets the value, so it can be slow in very large grids.
new 12.0 upd 13.0 <Cfg> int

ColIndexType

[0]
Bit array of flags for the ColIndex.
1.bit (&1)Count also deleted columns
2.bit (&2)Count also filtered columns not implemented yet
3.bit (&4)Count also manually hidden columns
4.bit (&8)Count also left section columns
5.bit (&16)Count also right section columns
6.bit (&32)Count also Panel and Gantt type columns and (since 13.0) RowIndex column
new 12.0 <Cfg> int

ColIndexStart

[1]
The index is created from this number. Useful to have all indexes the same length (e.g. starting from 1000).
new 12.0 <Cfg> string

ColIndexChars

[]
Characters to build the index. By default the index is a number. Setting the ColIndexChars="ABCDEFGHIJKLMNOPQRSTUVWXYZ" use alphabetical indexes.
new 12.0 <Cfg> int

AutoCols

[0]
If set, automatically generates given number of columns. Used only when ColIndex is set.
The columns are generated as last columns in middle section.
The column gets its Name as its generated index. If the index is a number, the Name gets "C" prefix, like C256. The column gets its Def = "Auto".
See also AutoColPages to add new columns on scroll right.
new 13.0 <Cfg> int[]

AutoWidths

A comma separated list of widths for individual columns created by AutoCols.
If the individual item is set to "0", the column is hidden. If the individual item is empty or not set, it is used default width.
new 12.0 <C> bool

NoIndex

[0]
If set to 1, the column will not be counted by ColIndex.
new 12.0 TCol variable int

HasIndex

[0]
Column position from 1 or 0 for column without index. On grid loading it is available in OnReady and later. It is not affected by ColIndexStart / ColIndexChars. Accessible as grid.Cols[col].HasIndex.
new 12.0 API method string

GetColByIndex

(type index, bool type = 0)
Returns column name according to its index. On grid loading it is available in OnReady and later.
For type = 0 The index is number from 1 as for column (HasIndex).
For type = 1 The index is number or string according to the displayed column index in ColIndex row.
new 12.0 API method type

GetColIndex

(string col, bool type = 0, type default = null)
Returns column index according to its name. On grid loading it is available in OnReady and later.
For type = 0 Returns number from 1 as the column (HasIndex).
For type = 1 Returns number or string as the displayed column index in ColIndex row.
If the column has not index, returns default.
new 12.0 API event bool

OnColIndex

(TGrid grid, string[] values)
Called on recalculate the ColIndex column. values contains the changed indexes that will be assigned after the event finishes. It is named array as new value by column name. The indexes are always from 1, the index to delete is set as "".
You can modify the values, but you cannot add or delete the items from the array.
Or you can assign your own index to the ColIndex column and true to not process the values, it is not possible if the index is used for calculated formula.