TreeGrid v6.0
Column API
In TreeGrid is column referenced always by its name as string.
By API there are accessible all grid columns set in XML and all their attributes and some runtime attributes. The columns are accessible by grid.Cols array as array of TCol objects.
Every column object contains its input XML attributes set by <C> tag, like Name, Width, Format etc.
API variable TCol[] Cols read only JavaScript named array of column objects .
All column objects accessible by their names, like grid.Cols[col].
All grid column objects can be iterated by for(var col in grid.Cols){ var C = grid.Cols[col]; ... } – it iterates randomly not by their positions.
API variable string[][]ColNames read only three JavaScript index arrays of column names .
Three arrays for the column sections ColNames[0] – left, [1] – mid, [2] – right. The array exists even if the section was not defined in XML.
Every array contains the column names sorted according to the position inside the section.
To iterate all column use such loops: for(var s=0;s<3;s++) for(var c=0;c<grid.ColNames[s].length;c++){ var col = grid.ColNames[s][c]; ... }
To iterate all visible columns you can use such loop for(var col = grid.GetFirstCol();col;col = grid.GetNextCol(col)) { ... }
API method string[] GetCols (string attr1, string attr2) new 6.0 .
Returns all columns (their names) in grid, in correct order in table.
If set attr1 and/or attr2, returns only columns that have set these attributes.
For example call grid.GetCols (“Visible”,”CanExport”) to get all exportable columns.
API method int[] GetSections ( ) .
Returns first and last actually visible section in grid [c1,c2]. c1 is 0 if left cols are visible, 1 otherwise, c2 is 3 if right cols are visible otherwise 2.
API method string GetFirstCol (int sec = null) .
Returns first visible column in grid or null
If set sec to column section index (0 – left, 1 – mid, 2 – right), it returns first visible column in given section or null
API method string GetLastCol (int sec = null) .
Returns last visible column in grid or null
If set sec to column section index (0 – left, 1 – mid, 2 – right), it returns last visible column in given section or null
API method string GetNextCol (string col) .
Returns next visible column according to its position
To iterate all visible columns you can use such loop for(var col = grid.GetFirstCol();col;col = grid.GetNextCol(col)) { ... }
API method string GetPrevCol (string col) .
Returns previous visible column according to its position
API method TCol AddCol (string col, int sec, int pos, int width, bool show = 0, string type = “Text”, string caption = col) upd 6.0.
Adds one new column to the table.
col is column name, sec is section of columns (0 – left, 1 – mid, 2 – right), pos is position is column position in its section (from 0)
width is column width or null for automatic computing, for show = 1 is column displayed in table, for show = 0 it is hidden.
type is set column Type attribute, caption is string displayed in all headers for this column.
New column will have default values from <D Name=’C’>.
Returns new column or null if column with given name already exists.
API method void DelCol (string col) .
Hides and deletes the column col. If the column does not exist, does nothing.
Does not delete any column values in rows or other cell attributes.
API method string GetCaption (string col) .
Returns column caption displayed in the first header - Header.
.