TreeGrid v6.0

Row moving and dragging

TreeGrid documentation index

 

Rows in TreeGrid can be dragged inside one grid or between any two grids. The dropped rows can be moved or copied.

Only variable rows can be moved or copied!

By default every row can be dragged and every row accepts every child as drop target.

To control which row can be dragged use row’s CanDrag attribute and/or OnStartDrag event.

To control which row accepts which child use Def and AcceptDef attributes. The row accepts as child only rows with Def attribute listed in the row’s AcceptDef array. The root rows are controlled by <Root AcceptDef/>.

All the Def and AcceptDef settings are described in Default rows documentation.

Dynamically you can control dropping by OnCanDrop and OnEndDrag events.

 

<Cfg>                bool       Dragging             [1]                                                                                                                                              .

If rows can be moved by mouse – the grid can be a source grid for drag / drop rows.

 

<Cfg>                bool       Dropping             [1]                                                                                                                                              .

If rows can be dropped to this grid – the grid can be a target grid for drag / drop rows.

 

<Cfg>                bool       DragCopy           [0]                                                                                                                                              .

For copying between two grids. If set to 1 in source grid, rows are copied instead of moved – the moved rows are not deleted in the source grid.

 

<Cfg>                bool       DragEdit              [0]                                                                                                                                               .

If set to 1, rows can be dragged even if grid is in edit mode.

In this case the grid finishes editing on mouse down at any other cell than edited one.

It is still not possible to drag row by the cell being edited.

 

<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          DragObject        [1]                                                                                                                                 new 6.0 .

What is shown under mouse cursor when dragging rows.

0 – nothing

1 – the first dragged row proxy. If dragged more rows, the border of the proxy is thicker

2 – row name or count of dragged rows, in Grid.CSS is represented by class GxDragObject.

the message is defined in Text.xml by <Lang><Text DragObjectMove DragObjectCopy DragObjectMoreMove DragObjectMoreCopy/></Lang>.

 

<Cfg>                bool       DropFixed          [0]                                                                                                                                              .

If set to 1, it is possible to drop rows above fixed sections.

If the row is dropped to head section, it is placed as the first root row, if the row is dropped to foot section, it is placed as the last root row.

 

<Cfg>                bool       ExpandOnDrag          [1]                                                                                                                                 .

If set 1, expands row when dragging row and mouse goes over the expand icon of not expanded row.

 

<Cfg>                int          ScrollOnDrag               [50]                                                                                                                 new 6.0; chg 7.0

If set, scrolls grid down if the dragging mouse hovers foot section and scrolls up if mouse hovers head section.

Since 7.0 it specifies the scrolling speed, for how many pixels will be scrolled in one step, the original value 1 is changed to 50.

 

<I>                     bool       CanDrag              [1]                                                                                                                                              .

If row can be moved by mouse dragging. Not applicable for fixed rows. Fixed rows cannot also be drop target.

 

<C>                   bool       CanDrag              [1]                                                                                                                                              .

If row can by caught by cell in this column and being dragged. Set it to 0 to let a user to select text in cell instead of dragging.

 

<I>                     int          Moved       [0]         Uploaded to server, supports Undo                                                                                          .

If and how the row has been moved inside the grid. 0 – no, 1 – to another position in the same parent, 2 – to another parent.

When sorting is enabled, the value 1 is not used.

When the row is moved between grids, it is marked as Added in target grid and Deleted in source grid. No Moved flag is set in this case.

After uploading changes to server or calling AcceptChanges the moved row just looses its state and becomes normal row.

 

<I>                     string    Parent        Uploaded to server                                                                                                                                 .

When the row is moved or added, this is id of the new parent row or position of page (from 0).

 

<I>                     string    Next              Uploaded to server                                                                                                                                 .

When the row is moved or added, this is id of the row below or “” if the row is the last row in its parent.

 

<I>                     string    Prev              Uploaded to server                                                                                                                                 .

When the row is moved or added, this is id of the row above or “” if the row is the first row in its parent.

 

<Panel>            bool       Move           [0]                                                                                                                                                           .

If the default Panel button Move is visible. This button is hidden also if <Cfg Dragging=”0”/>. This button is inactive when the row has CanDrag=’0’.

Dragging this button moves the row. Use this button if dragging row by cells has different function like selecting cells.

 

API event          bool       OnStartDrag     (TGrid grid, TRow row, string col, bool more)                                                                       .

Called before the row is being dragged. Return true to suppress dragging the row.

row is the caught row, col is column where the row is caught, more is true when more selected rows will be dragged together.

 

API event          int          OnEndDrag       (TGrid grid, TRow row, TGrid togrid, TRow torow, int type, int X, int Y)                                        .

Called after the dragged row is dropped. It is called for any drop, even not permitted.

grid, row – dragged source row, togrid, torow – drop target – row under mouse cursor

type - 0 – cannot drop, 1 – above torow, 2 – to the end of children of torow, 3 – below torow

X, Y – mouse cursor position on screen (related to browser window)

togrid is never null, it is the last grid that was under mouse cursor. torow is null when no row is under mouse cursor in time of drop.

Return new type to change dropping results.

 

API event          int          OnCanDrop      (TGrid grid, TRow row, TGrid togrid, TRow torow, int type, bool copy)        renamed 6.0  .

Called during dragging row above other rows (drop targets) to find out if and how row can be dropped to this target.

It is called even if the dropping here is restricted (with type = 0). It is not called for grids with <Cfg Dropping=’0’/>.

grid, row – dragged source row, togrid, torow – drop target – row under mouse cursor,

type - 0 – cannot drop, 1 – above torow, 2 – to the end of children of torow, 3 – below torow

copy is true if the source row will be copied, not moved.

Return new type to change dropping permits.

This event controls dropping. To control which rows can be dragged (caught), set the row attribute CanDrag or set <Cfg Dragging> for whole grid or use OnStartDrag event.

 

API event          int          OnRowMoveToGrid          (TGrid grid, TRow row, TGrid togrid, TRow torow, bool copy)          upd 7.0 .

Called after row is moved or copied to another grid. Called from function MoveRowsToGrid ( ).

In time of call new row (torow) is positioned and displayed in target grid (togrid).

Old row (row) is still not deleted in source grid (grid).

If copy = true, old row will not be deleted.

return null to default behavior according to copy, or 0 to move, 1 to copy and -1 to remove source row.

 

API event          void       OnRowMove   (TGrid grid, TRow row, TRow oldparent, TRow oldnext)                                                    .

Called after row has been moved inside one grid. Called from function MoveRow ( ).

The row is still displayed in old position but have new settings.

oldparent is original parent of the row, oldnext is original next sibling.

 

API method      void       MoveRow           (TRow row, TRow parent, TRow next, bool show = false)                                                   .

Moves row with all its children to the parent’s children in front of next row. parent can be row, page or null. If show = true, displays changes.

If next is null, moves new row as last parent’s child. If parent and next are null, moves row as the last root row.

If the row is first row in spanned range (has set RowSpan for some cell), it moves the whole range.

 

API method      void       MoveRows       (TRow row, TRow rowto, int type)                                                                                         .

Moves row with all its children inside one grid. It converts its parameters and calls MoveRow.

row is the row to move, type - 1 – above torow, 2 – to the end of children of torow, 3 – below torow

If the row is first row in spanned range (has set RowSpan for some cell), it moves the whole range.

 

API method      TRow    MoveRowsToGrid (TRow row, TGrid togrid, TRow torow, int type, int copy = 1)                    chg 7.0 .

Moves or copies row to another (or the same) grid. Displays changes. Returns added row from source (calling) grid.

row is the row to move or copy, togrid is target grid. If target grid is the same as source grid it calls MoveRows.

type - 1 – above torow, 2 – to the end of children of torow, 3 – below torow

If copy is 0, row (and its children) is added to target grid (marked as Added) and deleted from source grid (marked as Deleted).

If copy is 1, row (and its children) is added to target grid, but it is not deleted from source grid.

If copy is 2, copies only row, without its children.

Copies all row and cell attributes except when replacing deleted row with the same id. Does not copy RowSpan.

If copy is 0 and in target grid already exists deleted row with the same id as source row, to the target grid is not added new row, but the existing target row is moved to new position and filled with cell values from source row and the source row is deleted!

If copy is 0 it preserves creating new and new rows when moving one row more times between two grids.

Since 7.0 replaces only deleted rows with the same id. Also copies all attributes not only values.

 

<Actions>                      DragRow              Attached to OnDragPanelMove and OnDragRow events, can be attached to OnDrag... events only           .

Starts dragging actual row with all its children to new position. Dropped row will be moved.

 

<Actions>                      DragSelected               Attached to OnDragRow events, can be attached to OnDrag... events only    .

Starts dragging selected rows with all their children to new position. Dropped rows will be moved.

Fails if actual row is not selected. It is possible to drag selected rows only by dragging one of them.

 

<Actions>                      DragCopy                         Not attached to any event, can be attached to OnDrag... events only        chg 7.0 .

Starts dragging actual row without its children to new position. Dropped row will be copied.

Like DragRow, but copies row, without its children.

Since 7.0 it fails also when set Adding=’0’ or Copying=’0’.

 

<Actions>                      DragSelectedCopy             Not attached to any event, can be attached to OnDrag... events only    chg 7.0 .

Starts dragging selected rows without their children to new position. Dropped rows will be copied.

Fails if actual row is not selected. It is possible to drag selected rows only by dragging one of them.

Like DragSelected, but copies rows, without their children

Since 7.0 it fails also when set Adding=’0’ or Copying=’0’.

 

<Actions>                      DragCopyChildren                          Not attached to any event, can be attached to OnDrag... events only           chg 7.0 .

Starts dragging actual row with all its children to new position. Dropped row will be copied.

Like DragRow, but copies row, with all its children

Since 7.0 it fails also when set Adding=’0’ or Copying=’0’.

 

<Actions>                      DragSelectedCopyChildren  Not attached to any event, can be attached to OnDrag... events only           chg 7.0 .

Starts dragging selected rows with their children to new position. Dropped rows will be copied.

Fails if actual row is not selected. It is possible to drag selected rows only by dragging one of them.

Like DragSelected, but copies rows, with all their children

Since 7.0 it fails also when set Adding=’0’ or Copying=’0’.