JSDO properties, methods, and events reference : afterFill event
  

afterFill event

Fires on the JSDO after a call to the fill( ) method executes and returns the results from the server to JSDO memory for a Read operation request on its Data Object resource.
Alias: afterRead
Applies to: progress.data.JSDO class
The following parameters appear in the signature of any event handler (callback) function (or functions) that you subscribe to this event:

Syntax

function ( jsdo , success , request )
jsdo
A reference to the JSDO that invoked the fill( ) method to initialize JSDO memory with the data in its resource. For more information, see the description of the jsdo property of the request object.
success
A boolean that is true if the Read operation on the resource was successful. For more information, see the description of the success property of the request object.
request
A reference to the request object returned after the fill( ) method completed execution either successfully or unsuccessfully. For more information, see the description of the request object.
Application code can subscribe a callback to this event by invoking the subscribe( ) method on a JSDO instance.

Example

The following code fragment subscribes the callback function, onAfterFill, to handle the afterFill event fired on the JSDO, myjsdo, after results are returned for a Read operation on a single-table resource, ttCustomer:
* subscribe to event */
myjsdo.subscribe( 'afterFill', onAfterFill );

myjsdo.fill();
    
function onAfterFill( jsdo , success , request ) {
var lenErrors,
errors,
errorType;
    if (success) {
        /* for example, add code to display all records on a list */
        jsdo.foreach(function (jsrecord) {
            /* you can reference the fields as jsrecord.data.field */
        });
    }
    else {/* Handle Read operation errors */
errors = jsdo.ttCustomer.getErrors();
lenErrors = errors.length;
for (var idxError=0; idxError < lenErrors; idxError++) {
switch(errors[idxError].type) {
case progress.data.JSDO.RETVAL:
errorType = "Server App Return Value: ";
break;
case progress.data.JSDO.APP_ERROR:
errorType = "Server App Error #"
+ errors[idxError].errorNum + ": ";
break;
case progress.data.JSDO.ERROR:
errorType = "Server General Error: ";
break;
}
/* Log error type and message for current error */
console.log("READ ERROR: " + errorType + errors[idxError].error);
/* Log additional HTTP text for web or other server errors */
if (errors[idxError].responseText) {
console.log("HTTP FULL TEXT: " + errors[idxError].responseText);
}
}
    }
    
};

See also:

beforeFill event, fill( ) method, subscribe( ) method (JSDO class), unsubscribe( ) method (JSDO class)