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

hasChanges( ) method

Returns true if JSDO memory contains any pending changes (with or without before-image data), and returns false if JSDO memory has no pending changes.
Return type: boolean
Applies to: progress.data.JSDO class

Syntax

hasChanges ( )
This method always returns true if any change to JSDO memory has marked a record object it contains as created, updated, or deleted.
This method always returns false if you execute it immediately after invoking any one of the following methods on the JSDO:
*fill( )
*saveChanges( ), if the autoApplyChanges property is also set to true
*acceptChanges( )
*rejectChanges( )
A typical use of this method is to determine if there are any changes in JSDO memory that you want to save to local storage using the JSDO saveLocal( ) method.

Example

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

/* Work done with the dataSet JSDO memory */
.
.
.
if (dataSet.hasChanges())
{
dataSet.saveLocal(progress.data.JSDO.CHANGES_ONLY);
}
else
{
dataSet.saveLocal(progress.data.JSDO.ALL_DATA);
}
The fragment first invokes the fill( ) method on a JSDO (dataSet) to load JSDO memory, sets the autoApplyChanges property on the JSDO to not automatically accept or reject changes saved to the server based on the success or failure of the save, 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, or to save only the pending changes, based on whether any pending changes currently exist in JSDO memory.

See also:

acceptChanges( ) method, autoApplyChanges property, fill( ) method, hasData( ) method, rejectChanges( ) method, saveChanges( ) method, saveLocal( ) method