Skip to content
🚀 Rapid Application Development with the App Builder

preDelete ​

The preDelete hook is executed before a row is deleted. It allows developers to prevent deletion based on custom logic.

Parameters ​

ParameterTypeDescription
tablereferenceTable instance and state.
appreferenceContext object app.
rowIdobjectThe primary key of the row to be deleted.

Structure parameter table ​

js
table: {
	instance: *ref_to_table_api,
	state: *ref_to_table_store,
	requery: *ref_to_requery_table_function,
}

The requery function supports two optional parameters:

js
requery(recalculateRowCount, enableLoadingFeedback)
  • recalculateRowCount: When true, forces a row count recalculation. (default: false)
  • enableLoadingFeedback: When false, disables the spinner and progress bar. (default: true)

Return Value ​

Return false to cancel the deletion, or true to proceed with the deletion.

✨ Example of a preDelete Hook ​

This example prevents deleting rows with an id greater than 40000.

js
((table, app) => {

	if (rowId?.id > 40000) {

    	wpda.alert("ERROR", "Delete not allowed!")		// Use built-in alert
        wpda.snackbar("Delete not allowed!", "error")   // Use built-in snackbar
      
        return false

    }

})