TreeGrid v6.0

Column API

TreeGrid documentation index

 

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 (or more) JavaScript index arrays of column names  chg 7.0 .

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)) { ... }

(New 7.0) When set ColPaging, it contains column pages, can be more than 3, in this structure: 0 Left, 1 – (N-2) Mid, (N-1) Right, where N is the ColNames.length

 

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, object param, bool show = 0, string type = “Text”, string caption = col)        chg 7.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)

param (new in 7.0) is an object with all parameters like for <C> tag, to preset them in the column, for example { Width:100, Type:”Lines”, CanSort:0 }

Before 7.0 version the param was integer and specified column width, it is still supported, but not recommended.

for show = 1 is column displayed in table, for show = 0 it is hidden and can be displayed by ShowCol method.

type is set column Type attribute (just for backward compatibility, it can be set in param), 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.