TreeGrid v6.0

Row deleting

TreeGrid documentation index

 

When a user deletes row, the row is not physically removed. The deleted row is marked as Deleted and is hidden or colored red depending on ShowDeleted.

The deleted row can be still undeleted, by a user if it is visible or by API.

After the changes are uploaded to server and server accepts the changes, the deleted row is physically removed from grid and its data.

 

<Cfg>                bool       Deleting   [1]                                                                                                                                                            .

If rows can be deleted from grid.

If set to 0, it disables Panel Delete button, the deleting actions and DeleteRow method. The DeleteRowT and DelRow are still working.

 

<Cfg>                bool       ShowDeleted [1]         Saved to cookies                                                                                                         .

If deleted rows are visible and colored.

If set to 1, deleted rows are still visible and can be undeleted. When deleting one row, no confirm message is displayed. The deleted rows are colored in red, it can be changed in Grid.css.

If set to 0, deleted rows are hidden and cannot be undeleted by user. When deleting one row, a confirm message is displayed.

Setting to 1 when AutoUpdate is true has no effect – the rows are immediately deleted.

 

<I>                     bool       CanDelete           [1/0]                                                                                                                                           .

If the row can be deleted.

By default variable rows can be deleted and fixed rows cannot. Deleting fixed rows is not good idea, fixed rows cannot be added.

 

<Header>          bool       CanDelete           [1]                                                                                                                                              .

If the Panel DeleteAll button is enabled. Header row itself can never be deleted.

 

<I>                     bool       Deleted     [0]         Uploaded to server, supports Undo                                                                                          .

It is set to 1 when the row has been deleted.

The row is hidden if ShowDeleted=’0’ or visible and colored red (by default setting in Grid.css) when ShowDeleted=’1’.

If the row is shown, it can be undeleted. Child row of deleted parent cannot be undeleted.

When user deletes row, all its children are automatically deleted to. When user undeletes the parent, all its children are undeleted too, except they were deleted directly.

In API, deleted children due its parent deletion has Deleted=’2’.

The deleted row is ignored in summary calculations. The deleted row cannot be moved and does not accept children by dragging or adding.

After uploading changes to server or calling AcceptChanges the deleted row is physically removed from grid.

 

<Panel>            bool       Delete         [1]                                                                                                                                                           .

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

Click to this button deletes row or undeletes deleted row.

 

API event          void       OnRowDelete              (TGrid grid, TRow row, int type)                                                                                .

Called before the row is deleted. Called after the row is marked as Deleted, but before it is hidden or colored.

Fires for every row being deleted, even for deleted children of deleted parent. First are deleted children and after them the parent.

type = 1 delete row, 2 delete row because its parent is deleted.

If row is removed by DelRow ( ), event is not fired!

 

API event          void       OnRowUndelete       (TGrid grid, TRow row)                                                                                              .

Called before the row is undeleted. Called after the row has cleared its Deleted attribute, but before it is shown or colored.

Fires for every row being undeleted, even for undeleted children of undeleted parent. First are undeleted children and after them the parent.

 

API event          int          OnCanRowDelete   (TGrid grid, TRow row, int type)                                                                                .

Called before row is deleted or undeleted. Called to find out if and how can the row be deleted or undeleted. It is not called for its children.

type = 0 – cannot delete, 1 – user must confirm deleting, 2 - delete, 3 – undelete.

Returns new type. Or return the type to not change the behavior. No return means 0. Returning 2 for deleted row and 3 for not deleted row has no effect.

If fires, when deleting selected rows, type = 1 has no meaning.

 

API event          bool       OnDeleteAll      (TGrid grid, int type)                                                                                                                .

Called before all selected rows are deleted or undeleted. Return true to suppress the action.

type = 0 undelete, 1 delete, 2 remove.

Remember, this event can be called more times, depending on Actions settings for event ClickHeaderDelete.

 

API method      void       DeleteRow         (TRow row, int type)                                                                                                                .

Deletes / undeletes row from grid. Displays changes. Prepares deleting and calls DeleteRowT ( ).

type1 – delete + confirm dialog, 2 – delete, 3 – undelete.

Deletes or undeletes row with its children. Only marks rows as deleted.

 

API method      void       DeleteRowT      (TRow row, int type, bool noshow = false)                                                                             .

Deletes / undeletes row from grid. Displays changes. type2 – delete, 3 – undelete.

Deletes or undeletes row with its children.

 

API method      void       RemoveRow    (TRow row)                                                                                                        renamed 6.0  .

Physically removes the row from grid and data. The row is really deleted, not just marked! For marking row as Deleted use DeleteRow().

Deleted rows are not in output data, thus server cannot see which rows was deleted (only by comparing with original data).

Only variable row can be removed.

Remember, removed row cannot be used in any API function, especially take care in loops, you cannot use GetNext / GetPrev functions with removed row.

 

<Actions>                      DeleteRow ...F                         Attached to OnDel and OnClickPanelDelete events                             .

Deletes actual or focused row, the row is marked as Deleted.

 

<Actions>                      UndeleteRow ...F                 Attached to OnDel and OnClickPanelDelete events                             .

Undeletes actual or focused row.

It is used only if the deleted rows are visible (<Cfg ShowDeleted=’1’/>.

To invert deletion use action setting “DeleteRow OR UndeleteRow”

 

<Actions>                      RemoveRow ...F                 Not attached to any event                                                                              .

Physically removes the row. The row will no longer exist in grid and cannot be updated to server!

 

<Actions>                      DeleteSelected                        Attached to OnCtrlDel and OnClickHeaderDelete events                 .

Deletes all selected rows. It fails if there is no selected row or all selected rows are deleted.

This action can be asynchronous!

 

<Actions>                      UndeleteSelected                Attached to OnCtrlDel and OnClickHeaderDelete events                 .

Undeletes all selected rows. It fails if there is no selected deleted row.

It is used only if the deleted rows are visible (<Cfg ShowDeleted=’1’/>.

To invert deletion use “UndeleteSelected OR DeleteSelected” - remember, here it depends on the order!

This action can be asynchronous!

 

<Actions>                      RemoveSelected                   Not attached to any event                                                                              .

Physically removes all selected rows. The rows will no longer exist in grid and cannot be updated to server!

This action can be asynchronous!