Skip to content

SaveSelectedRow - cCJGrid

Attempts to save the current SelectedRow

Type: Function
Return Data Type: Boolean

Syntax

Function SaveSelectedRow Returns Boolean

Call Example

Get SaveSelectedRow to BooleanVariable

Description

SaveSelectedRow attempts to save the changes in the SelectedRow. When changing rows, changes in the row must be either saved or cleared (restored). pbAutoSave determines if a row should be saved or cleared. Normally, pbAutoSave is set true, so a save is attempted. When pbAutoSave is true and a row change is attempted from a changed row, SaveSelectedRow is called to perform the save. If the save fails and returns True, the row change will not occur.

In addition, SaveSelectedRow is called by Request_Save, which means it is called when the user presses the save key (F2).

If the grid is non-data aware (cCJGrid / cCJGridDataSource) a save will commit any changes made in the SelectedRow and update the datasource array. If the grid is data aware (cDbCJGrid / cDbCJGridDataSource) the datasource will use the DataDictionary to perform the save, which will result in the record being updated in the datasource and saved to the backend database. Although these two types of saves are different, the process of the save is the same. SaveSelectedRow does the following:

  1. It checks if a save is needed by calling ShouldSaveSelectedRow. If a save is not needed, it returns false.

  2. It checks to see if saves are allowed by calling CanSaveRow. If a save is not allowed, it returns true.

  3. It validates the row's data by calling ValidateRow. If any column value fails validation, it return true. With data aware grids, the validation process will apply validation rules defined in the data dictionaries.

  4. If calls Verify_Save, which provides a hook for user verification of a save. If the verification fails, it returns true.

  5. It sends SaveSelectedRow to the datasource object. The datasource object performs the actual save, which may involve updating just the datasource or may involve updating external data such as data dictionaries and tables. This operation can also fail. It returns True if the save failed and False if it succeeded.

With a default non-data aware grid, it may appear that this save process does not occur. For example, if you change rows, the grid will appear to simply changes the row. While you are always allowed to save the row, there are no verifications and there are no validations, the save will always silently succeed and it will appear that the grid just changes rows. The save process does occur.

Return Value

Returns False if the save succeeded, True if the save was cancelled.