ondbload event



The ondbload event runs whenever data has been loaded from the database into a database-driven widget.

There is a variable that is pre-set when this event is run.

  • response - information about the database response.  This is an object ("data structure") that contains the following fields:

    • success - a boolean field set to true or false.  When true, the data has been retrieved and loaded into the widget.  When false, the error field will be populated.

    • id - the id of the widget that was loaded

    • error - an object containing the error that occured. It contains the following subfields:

      • operation - the operation being performed when the error occurred

      • id - error id

      • text - first level text of error

      • text2 - second level text of the error

This event is commonly used with the pui.showLastError() API to display an error when the SQL statement to load a database driven grid fails. 

Example: To pop-up an error when the SQL statement to load a database-driven grid fails:

if (!response.success) { pui.showLastError(); }



Example: To format your own custom error message:

if (!response.success) { var message = "Database load for " + response.id + " failed!\n" + "Reason: " + response.error.id + " - " + response.error.text; alert(message); }



Example: You may wish to hide a widget when an error occurred, or show it if it loaded successfully:

if (response.success) { applyProperty(response.id, "visibility", "visible"); } else { applyProperty(response.id, "visibility", "hidden"); }