PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
  • Overview
  • Principle
  • Reminder: the synchronization code is triggered when the three following conditions are fulfilled
  • Implementation
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Custom synchronization for Table controls based on a data file
Overview
In some cases, you may want to use a custom synchronization for Table controls based on a data file. For example, the synchronization must be managed between:
  • the page displayed in the browser. This page contains a Table control based on a data file.
  • the corresponding page context found on the server.
This custom management of the synchronization is used to update the page context on the server according to the page displayed in the browser. No out-of-sync message is displayed on the browser.
Principle
The custom synchronization method for Table controls based on a data file relies on a piece of information hidden in the page: the identifier for the record selected in the Table control based on a data file.
The synchronization consists in reading the current record in the Table control on the server and refreshing the control. These operations are performed in the synchronization code.

Reminder: the synchronization code is triggered when the three following conditions are fulfilled

  • the page displayed on the browser no longer corresponds to the page context on the server.
  • the user runs a server code by clicking a link or a button.
  • "Call the page synchronization process if the user pressed the browser Back button" has not been unchecked in the "Advanced" tab of the control description.
Implementation
To customize the synchronization of Table controls based on a data file:
  1. Check whether the mechanism for synchronization management is enabled.
    • at the page level ("Using the browser's "Back" button" corresponding to "Allowed (runs the synchronization code)" in the "UI" tab of the page description).
    • at each button to manage the Table control or perform an action on the record selected in the control (option "Call the page synchronization process if the user pressed the browser Back button" not unchecked in the "Advanced" tab of the control description).
  2. Make sure that the option "Send value of controls to server (HTML: submit) " is checked for the "Link" columns in your Table control ("Detail" tab of the column). These columns are used to perform the click code on a row of the Table control.
  3. Create an invisible control (name "UNIKID" for example). This control must contain the identifier of the row selected in the Table control by the user. The initialization of this control must be performed:
    • in the initialization code of the Table control.
    • in the click code of a Table control row.
      Example of code used to initialize the control with the identifier of Customer: UNIKID = CUSTOMER.CUSTOMERID
  4. Create (if necessary) the buttons (or links) used to display the next or previous page of the Table control. The code of these buttons must initialize the invisible control created in step 3.
  5. Customize the synchronization code of the current page. This synchronization code must:
    • re-read the record corresponding to the identifier stored in the hidden control.
    • redisplay the Table control from this record
An example of synchronization code can be:
// Retrieve the value of the hidden control
CurrentRecord = PageParameter(UNIKID)
 
// Find the record
HReadSeek(CUSTOMER, CUSTOMERID, CurrentRecord)
IF HFound() = True THEN
// Modify the search key in case
// where the search key for the Table control is
// different from the value of the key stored in the invisible control
HChangeKey(CUSTOMER, Name)
// Refresh the Table control
TableDisplay(TABLE_MyTable, taRefresh)
// Retrieves the number of the current row
CurrentRow = PageParameter(TABLE_MyTable)
// Positions the bar in the Table control
TableSelectPlus(TABLE_MyTable, CurrentRow)
// Continues the application without displaying a message
ChangeAction(caContinue)
ELSE
ChangeAction(caError)
END
Minimum version required
  • Version 9
Comments
Click [Add] to post a comment