postinsert
This article is about the postinsert UDB event handler.
postinsert
The postinsert event may be called from web pages developed in Web Designer and processed by a USoft page engine service.
| Event | Applies to | Occurs when |
|---|---|---|
postinsert | Data source objects (UdbDataSource) of Table type | Immediately after a row is added to the data source's in-memory row set |
This event is triggered internally by the UdbRowSet class, from its insert() method, right after the new row has been spliced into the row set's in-memory row collection (and any manipulation bookkeeping and initial values have been applied). It only fires for data sources of Table type.
This is a lower-level, more immediate notification than the rowpostcreate event: postinsert occurs as soon as the row is present in the row set, without waiting for the rest of the create processing (such as selecting the new row) to complete.
Purpose
You can use this event to react as soon as a row has actually been added to a data source's in-memory data, for example to update client-side bookkeeping that tracks the rows currently held by the data source.
How to use
Find or create an Event Listener object with Event Type = postinsert. Event Listeners are in the Web Designer Controls catalog:
Insert the event listener into the data source object. Insert a callClientScript action into the event listener. Use this action's Script property to code the behaviour that you want to see when the event occurs.
You are implicitly associating the event with an event handler function. This function has an options parameter. For available options, see the Options section at the end of this help topic:
function(*event*, *options*){ ... }
Or you can create the event handler more explicitly by calling $.udb('data-source').on().
Options
When the event occurs, the following event handler function is called. You can use this function's options parameter in your event scripting.
function( *event*, *options* )
*event* ::= jQuery.Event
*options* ::= *event-options*
*event-options* ::= {
row: *row*
}
Event contains the run-time details of the triggered event, of the event type stated above.
This syntax means that you can access an option by scripting
options.*option*
Row is the UdbRecord object that was just added to the row set's in-memory row collection.