Row deleting
TreeGrid documentation
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
RemoveRow are still working.
<Cfg> bool
ShowDeleted
[1] Saved to cookies
If deleted rows and columns are visible and colored.
If set to
1, deleted rows and columns are still visible and can be undeleted. The deleted rows are colored in red, it can be changed in Grid.css.
If set to
0, deleted rows and columns are hidden and cannot be undeleted by a user.
Setting to
1 when
AutoUpdate is true has no effect - the rows are immediately deleted.
new 12.0 <Cfg> int
DeleteMessage
[1]
If the confirmation message for deleting row, selected rows, column and selected columns will be shown.
0 - never,
1 - only if
ShowDeleted is on,
2 always.
<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.
upd 12.0 <Header> bool
CanDelete
[1]
Deprecated since 12.0. Use Panel Buttons or Panel value instead to define the panel buttons for header row.
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.
<C> 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.
Used only if the Panel Buttons and the cell value are not set.
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 RemoveRow ( ), 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.
upd 11.0 API event int
OnCanRowDelete
(TGrid grid, TRow row, int type, TRow[ ] rows)
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.
Return new type. Or return the
type to not change the behavior. 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.
(Since 11.0) rows are set if called on deleting selected rows and contain all the selected rows to delete or undelete. For every of these rows is called the OnCanRowDelete.
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.
upd 12.0 API method bool
DeleteRow
(TRow row, int type, bool test = 0)
Deletes / undeletes row from grid. Displays changes. Prepares deleting and calls
DeleteRowT ( ).
type =
1 - delete + confirm dialog,
2 - delete,
3 - undelete.
Deletes or undeletes row with its children. Only marks rows as deleted.
Returns true if the deletion was done.
(Since 12.0) If set
test =
1, does not delete row, only tests if it is possible, but does
not show confirm message, takes it as confirmed.
API method void
DeleteRowT
(TRow row, int type, bool noshow = false)
Deletes / undeletes row from grid. Displays changes.
type =
2 - delete,
3 - undelete.
Deletes or undeletes row with its children.
renamed 6.0 API method void
RemoveRow
(TRow row)
Physically removes the row from grid and data.
The row is really deleted, not just marked! For marking row as Deleted use
DeleteRow() instead.
Deleted rows are not in output data, thus server cannot see which rows were 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.
new 12.0 API method int
DeleteRows
(TRow[ ] rows, int del = 1)
Deletes (
del =
1), or undeletes (
del =
0) or removes (
del =
2) all given rows in grid.
Returns final count of affected rows.
<Actions>
DeleteRow ...F
Attached to OnDel and OnClickPanelDelete events
Deletes actual or focused row, the row is marked as
Deleted.
<Actions>
DeleteRow ...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 actual or focused row. The row will no longer exist in grid and cannot be updated to server!
new 12.0 <Actions>
DeleteRows ...F
Not attached to any event
Deletes all focused rows, the rows are marked as
Deleted. Without ...F fails if the actual row is not focused.
This action can be asynchronous!
new 12.0 <Actions>
UndeleteRows ...F
Not attached to any event
Undeletes all focused rows. Without ...F fails is the actual row if not focused.
This action can be asynchronous!
new 12.0 <Actions>
RemoveRows ...F
Not attached to any event
Physically removes all focused rows. The rows will no longer exist in grid and cannot be updated to server! Without ...F fails if the actual row is not focused.
This action can be asynchronous!
chg 12.0 <Actions>
DeleteSelected ...F
Attached to OnCtrlDel and OnClickHeaderDelete events
Deletes all selected rows. It fails if there is no selected row or all selected rows are deleted.
(Since 12.0) Without ...F fails if the actual row is not selected.
This action can be asynchronous!
chg 12.0 <Actions>
UndeleteSelected ...F
Attached to OnCtrlDel and OnClickHeaderDelete events
Undeletes all selected rows. It fails if there is no selected deleted row.
(Since 12.0) Without ...F fails if the actual row is not selected.
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!
chg 12.0 <Actions>
RemoveSelected ...F
Not attached to any event
Physically removes all selected rows. The rows will no longer exist in grid and cannot be updated to server!
(Since 12.0) Without ...F fails if the actual row is not selected.
This action can be asynchronous!