OnWriteConflict Event
Description
Fires when a write conflict occurs.
Discussion
This event can be used to override the default write conflict error message with a custom message. The event handler should return the HTML text you want to display for the write conflict message. If the event handler returns a blank value, then the default write conflict message will be displayed.
The following variables are available to you in the event:
- Variable
- Description
- e.arr
A property array with an entry for each field that had a write conflict:
- field_name
The name of the field with the write conflict
- currentValueInTable
The value for this field that is currently stored in the table
- valueWhenUserStartedEditing
The value in the field when the user began to edit the record
- e.tmpl
The grid component definition
- e.rtc
Run-time calculations (allows you to pass data to other event handlers)
- e.__si
State information
Example
The following example shows how you can use the data in the e.arr array:
dim i as n dim count as n count = e.arr.size() dim fieldsWithErrors as c for i = 1 to count fieldsWithErrors = fieldsWithErrors + e.arr[i].field_name + "<br />" + crlf() next i OnWriteConflict = "<b>A write conflict occurred.</b> The following fields have conflicts:<br />" + fieldsWithErrors
Setting State Variables
You can also set state variables in this event. The value of any state variables will be available in all subsequent ajax callbacks (in the e.__si2 object).
To set a state variable:
e._state.myvar1 = "value1" e._state.myvar2 = "value2"
Videos
Customize the on Write Conflict Message
The Grid Component uses "Optimistic record locking" to prevent one user from overwriting another user's edits when two users edit the same record at the same time. The OnWriteConflict event handler allows you to customize the Write Conflict error message.