strict warning: Only variables should be assigned by reference in /home/itechpros/servoyguy.com/sites/all/modules/links/links.inc on line 1434.

Save and Restore Foundsets

Source: Sanneke Aleman, Servoy

To Save a foundset:

/******************************************  
Purpose: to save a foundset in when entering a find and the user wants to cancel  
******************************************/  
globals.svy_sea_foundset = new Object()  
globals.svy_sea_foundset.form = 'customers'  
//  save the sql and parameters  
globals.svy_sea_foundset.sql = databaseManager.getSQL(forms[globals.svy_sea_foundset.form].foundset) 
globals.svy_sea_foundset.parameters = databaseManager.getSQLParameters(forms[globals.svy_sea_foundset.form].foundset) 
//  save the index  
globals.svy_sea_foundset.index = forms[globals.svy_sea_foundset.form].controller.getSelectedIndex() 

 

To Restore a Foundset

/******************************************  
Purpose: to restore a saved foundset in case you enter a find and the user wants to cancel  
Parameters: globals.svy_sea_foundset contains the form, sql, parameters and index  
******************************************/  
// 1 load all records  
forms[globals.svy_sea_foundset.form].controller.loadAllRecords()  
//2 load records on to form  
forms[globals.svy_sea_foundset.form].controller.loadRecords(globals.svy_sea_foundset.sql,globals.svy_sea_foundset.parameters); 
//3 set selected record.  
forms[globals.svy_sea_foundset.form].controller.setSelectedIndex(globals.svy_sea_foundset.index)