SMART datagrid v.1 > Examples

[ grids ver.1.3.8]   Back  Forward

Row Deleting  Example

The user can delete the currently selected rows by Ctrl+Del keys. If the list of the rows which has been requested to delete is sent to DataSet and the data set actually deletes each data row connected to the grid rows in this list, the result will be reflected back to the grid. 

To enable the user delete, deletable of GridBase.editOptions should be set as true first (The default value is false). Also, if EditOptions.confirmWhenDelete is true (the default value), a confirmation dialog box specified through EditOptions.deleteMessage will be displayed before beginning to delete. 

  

Grid - 1
rows

Similarly as Row Updating or Row Inserting, after deleting the data rows in the data set, GridDataSet.onRowsDeleted event will be fired, and just before deleting, GridDataSet.onRowsDeleting event will be fired. If explicitly return false within this event handler, they will not be deleted. 

In addition, before the grid transfers delete request to the data set, onDeleting event will be fired, and if explicitly return false within this event handler as well, Row Deleting will be cancelled. 


Code -1
    grdMain.onDeleting = function (grid, rowIndices) {
        if ($('#chkEventDeletable').is(':checked')) {
            return false;
        }
    };

Soft Delete

When the user wants to delete the selected rows by ctrl+del keys, he can just change the state of the rows as deleted rather than to actually remove them from the data set. If specify DataSet.softDelete property as true and delete the data rows, the state of DataRowState.CREATED rows will be changed as CREATE_AND_DELETED, and the rest will be changed as DELETED

After this, he can request the server to delete the rows in a deleted state all at once. Also, he can restore the rows in a deleted state. 

 

 

 

View Source JSP 

See Also
DataSet.softDelete
EditOptions
GridBase.editOptions
GridBase.onDeleting
GridDataSet.onRowsDeleting
GridDataSet.onRowsDeleted
Examples
Row Inserting
Row Updating
Cell Editing
State Cells
Edit Events
Edit Keys