JSDO properties, methods, and events reference : hasData( ) method
  

hasData( ) method

Returns true if record objects can be found in any of the tables referenced in JSDO memory (with or without pending changes), or in only the single table referenced on the JSDO, depending on how the method is called; and returns false if no record objects are found in either case.
Return type: boolean
Applies to: progress.data.JSDO class, table reference property (JSDO class)

Syntax

jsdo-ref.hasData ( )
jsdo-ref.table-ref.hasData ( )
jsdo-ref
A reference to the JSDO. If you call the method on jsdo-ref, the method verifies if any data is available in the JSDO, whether it is created for a single-table or a multi-table resource.
table-ref
A table reference on the JSDO. If you call the method on table-ref, the method verifies if any data is available in the referenced table. If the useRelationships property is true, this includes related data in any other JSDO table(s) with which the referenced table has a parent-child relationship in the JSDO.
This method always returns true immediately after the fill( ) method successfully loads JSDO memory with one or more record objects.
Three cases where this method returns false include when executing this method:
1. After a JSDO is instantiated but before fill( ) or any other method (such as addRecords( )) has been invoked to load its JSDO memory with records
2. After the fill( ) method completes successfully, but returns no records, possibly because none match the specification of its filter parameter
3. After the saveChanges( ) method completes successfully on a JSDO, where its autoApplyChanges property set to true and all the records in the specified JSDO, or its table reference, were marked for deletion
Two typical uses of this method include determining if there is any data in JSDO memory that you might want to save in local storage using the JSDO saveLocal( ) method, or that you might not want to lose by replacing JSDO memory, using the JSDO readLocal( ) method, with other data previously saved in local storage.

Example

The following code fragment shows an example of how you might use hasData( ) to decide when to save JSDO memory to local storage:
dataSet = new progress.data.JSDO( 'dsStaticData' );
dataSet.fill();

/* Work done with the dataSet JSDO memory */
.
.
.
if (dataSet.hasData())
{
dataSet.saveLocal();
}
The fragment first invokes the fill( ) method on a JSDO (dataSet) to load JSDO memory, and after a certain amount of work is done with the JSDO, decides to save all the data in JSDO memory to the default local storage area when it finds that records exist in JSDO memory to save.

See also:

addRecords( ) method, fill( ) method, hasChanges( ) method, saveChanges( ) method, readLocal( ) method, saveLocal( ) method