EJS TreeGrid documentation

Column position and moving

TreeGrid documentation index

 

There are three column sections in grid – Left (0), Mid (1) and Right (2). In API methods are the sections identified by their indexes (0,1,2).

The Left (0) and Right (2) sections are fixed sections by default and always show all its content and no horizontal scrollbars. It is possible to have scrollable also the Left and Right section, see Section widths.

The Mid (1) section is positioned between Left and Right section and its content can be scrolled horizontally.

 

Column are placed into its section in input XML, in <LeftCols> (Left), <Cols> (Mid), <RightCols> (Right).

Column position inside section is set by the position of <C> tag inside its XML section <LeftCols>, <Cols>, <RightCols>.

The column position is saved to cookies, so the mentioned position is used only first time. To not save the position to cookies set <Cfg ColsPosLap=’1’/> or <ColsLap=’1’/>.

 

The columns can be moved by a user by mouse dragging, inside or among sections, controlled by <C CanMove/> attribute.

Or can be moved by API method MoveCol.

 

<C>                 int        CanMove           [2/0]                                                                                                    chg 6.3.

If and how column can be moved by a user - dragged by mouse.

0 – no

1 – only inside its section (Left, Mid, Right)

2 – inside and also between sections – user can freeze variable columns and vice versa.

For spanned columns see also Group attribute.

By default it is 2 for all columns except Panel that has 0.

When column has CanMove=’0’, since 6.3 can be moved columns right to this column in left section, left to it in right section and both side in variable columns.

 

<C>                 int        Block         [0]                                                                                                          renamed 9.2.

Controls moving column, it is useful especially if there are some cells spanned to or from other columns.

If set to > 0, it is the block the column belongs to. Create blocks that contain the spanned cells. The blocks must be continuous.

The columns can be moved only inside its block and any other column cannot be moved into the block from outside.

The first (left) column in the block cannot be moved within the block and also must stay the first.

The whole block can be moved by dragging the first left column to another location.

It also preserves splitting block of columns to more pages when printing and for column paging.

Since 9.2 it was renamed from Group

 

<Cfg>               bool      ColMoving        [1]                                                                                                                  .

If columns can be moved by a user -  dragged by mouse. Use column CanMove attribute to specify if and how can be individual columns moved.

 

<Cfg>              bool      ColsPosLap                                                                                                                          .

Suppresses loading column positions from cookies and always use their positions in input XML.

 

<Cfg>              bool      ColsLap                                                                                                                                    .

Suppresses loading column positions, visibility and widths from cookies and always use the settings in input XML.

 

<Cfg>              bool      ShowDrag         [1]        Saved to cookies, to not load it, set ShowDragLap=’1’                        .

If shows dragged object under mouse cursor. The dragged row(s) or moved column(s).

It can be changed by a user in configuration menu

 

<Cfg>              int        ScrollColOnDrag     [100]                                                                                       new 7.0.

The step (speed) when automatically scrolling column section horizontally while dragging column on the left or right edge.

 

<Cfg>               bool      AllCols     [0]                                                                                                                   new 7.0.

If set in input data XML, it says that the XML contains all columns definition and their position in <Cols> tag will change their position in grid.

Useful to set to change already defined columns position in later XML

It is cleared before every input XML and must be defined before all <LeftCols>,<Cols> and <RightCols> definition.

 

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

Starts moving column by mouse.

By default is the action attached to event OnDragHeader (dragging header cell).

 

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

Called after column is moved to another position by a user (not by API).

 

API method     void      MoveCol (string col, string tocol, bool right, bool noshow = 0) or (string col, int sec, bool last, bool noshow = 0)  upd 6.0.

Moves column to new position. If noshow is set, does not display changes and needs to call Render.

a) Moves column col in front of column tocol (or after tocol if right is 1).

b) Moves column col to section sec (0 – left, 1 – mid, 2 – right), to beginning (or to the end if last is 1). Use when destination section is empty.

Remember, moving column is slow process, much slower than moving row, all the column cells must be moved one by one.

Remember, this function can re-render the whole grid in some cases (when it leads to hide or show the whole column section)

 

API method     void      ChangeColsPositions    (string[] leftcols, string[] cols, string[] rightcols)            chg 7.0.

Changes positions of all columns in grid and splits them to sections.

All three arguments are Arrays of column names sorted according to their positions in given section.

Since 7.0 it can be called only in OnLoaded or OnCfgLoaded to change the column positions on grid start.

All column names in grid must be given!

It does not save changes to cookies.

It does not update horizontally spanned cells!

 

API TCol var.   int        MainSec  read only                                                                                                        new 7.0.

Column section - 0 Left, 1 Mid, 2 Right

 

API TCol var.   int        Sec  read only                                                                                                                    chg 7.0.

Column section/page - 0 Left, 1 Mid, 2 Right

(New 7.0) When set ColPaging, it is number of column page, 0 Left, 1 – (N-2) Mid, (N-1) Right, where N is the ColNames.length

 

API TCol var.   int        Pos  read only                                                                                                                                .

Column position inside its section / page Sec, from 0. All columns including hidden.