Client Data Validation
Summary
- Client-side validation in AdapTable can be used to prevent invalid Edits from completing
- They are essentially a special type of Alert
AdapTable provides Client Data Validation via Alerts (defined in Alert State)
Find Out More
AdapTable also offers Server Validation where the validation is handled externally
These Data Validation rules will prevent cell edits before the new value is sent to the server.
Note
- Ulitmately, these are simply Alerts with the
PreventEditproperty in the Alert Definition to true. - If the Alert Rule is broken, AdapTable will undo the cell edit and fire the Alert.
This avoids the irritating scenario where an edit is made and commmitted which all other users of the application see before server validation forces the cell to 'jump back' to its initial value.
Caution
- This is not the same as Pre-Edit Validation which prevents all edits to read-only cells
- Cllient Data validation is for the use case where a cell is editable but not all edits are necessarily valid
- In this (slightly contrived) example, we have prevented cells in the
Languagecolumn being changed to Python. - We have set the Alert to display a Toast Notification with a custom Message, and a Type of
Error, to appear at the top of the Grid.
Expand to see the Alert Definition
- Change a cell in the Language column to
Pythonand see how it triggers a Prevent Edit Alert - Or go a stage further and create an Alert with a custom form enabling users to provide a new value. This can be achieved via an Adaptable Form with 2 Buttons that reference Grid API methods when clicked.
Find Out More
- See Validation Alerts for more details
- Alerts with Data Validation Rules are defined in Alert Initial State
FAQ
Why add Prevent Edit Alerts which perform validation on the client - surely it should take place on the server? That is correct, validation should ideally take place on the server and hopefully it does for our users. And AdapTable offers Server Validation for this reason. Instead Prevent Edit Alerts specifically deal with 3 common validation-related use cases:
-
add an extra level of validation so that you can prevent edits which are usually permitted, but which in particular scenarios or use cases should be avoided
-
avoid unnecessary round trips to the server, particularly if this has other knock-on consequences or effect other users that might see their screen flash first with the new value and then again with the old value
-
as a temporary measure before Server Validation has been added; like all AdapTable objects, Alert Definitions will come into effect immediately after that they are created in the UI - there is no down-time needed, nor any custom development required, and no systems need to be restarted