Using JSDOs to create mobile and web clients : Accessing standard CRUD and Submit operations : Read operation example
  

Read operation example

To load data into JSDO memory on the client, you call the fill( ) method on the JSDO, passing an optional parameter to specify selection criteria as either an object or a string. This executes the ABL or Rollbase server routine that implements the Data Object Read operation. Each time fill( ) is called, all records currently in JSDO memory are cleared and replaced by the records returned by the method.
When you access a Progress Data Service from the Telerik Platform and the JSDO dialect of the Kendo UI DataSource calls fill( ) on its JSDO, the DataSource passes an object parameter to the method. This object contains properties specified according to DataSource requirements to select, order, and organize the return of the records from the server. The Data Object resource on the server then receives the DataSource selection criteria specified by this object in the form of a Progress-defined JSON Filter Pattern (JFP). Note that the resource Read operation must be programmed to handle this JFP according to the requirements of the specific Progress Data Object Service (OpenEdge or Rollbase). For more information, see the description of the fill( ) method.
If you are calling this method yourself, you can use a string to specify the selection criteria, again, according to the requirements of the Data Object resource whose data you are reading. If you do not pass a parameter to fill( ), the records returned to the client depend entirely on the implementation of the resource Read operation. For more information, see the description of the fill( ) method.
When you call the fill( ) method, if jQuery Promises are supported in your environment, it returns a Promise object on which you can register callbacks to handle completion of the Read operation that it executes. Otherwise, you can subscribe event callbacks to handle the results of the Read operation:
Operation results are thus returned as follows:
1. The JSDO fires an afterFill event for any callbacks you have subscribed to handle the event.
2. Any returned Promise object executes the Promise callbacks that you have registered, depending on the operation results.
Note that before any callbacks execute, if the Read operation completes successfully, the working record for each JSDO table reference is set to its first record returned, depending on any active parent-child relationships. Thus for each child table reference, the first record is determined by its relationship to the related working record in its parent.
For more information on handling fill( ) method results, see the description of the fill( ) method.
Following is an example showing an OpenEdge ABL implementation of the Read operation and its invocation on a JSDO.
Note: The bold code in the JavaScript examples primarily trace the path of referenced JSDO method and callback parameters, as well as key code elements in the example, including those elements that are directly or indirectly referenced in the example description and notes.
* An OpenEdge ABL implementation for Read
* Client JavaScript code: Read