Make the following changes, ignoring the error marks:
The cellClicked function is invoked when the user clicks a cell in the data grid.
function cellClicked(myGrid DataGrid in)
selectedPayment = allPayments_ui.getSelection()[1] as paymentRec;
selectedPayment_form.publish();
end
First, the cellClicked function updates the selectedPayment record with data from a single data-grid row. That row can include more fields than are displayed to the user. In this application, the single row in the data grid will have come from a single row in the database.
The Form Manager provides various benefits but is essentially a collection of controllers.
data = allPayments as any[]
allPayments_ui.getSelection()[1] as paymentRec
In each case, the as clause provides the necessary cast.
To add the formatter function:
You can test your recent changes even before you gain access to the database.
You now declare a service-access variable, which will let you communicate with the service that you defined earlier.
To create the variable:
Begin by creating the function that reads all data.
Next, create the function that adds sample data.
Next, create the function that adds data.
Create the function that deletes data.
To initialize the data grid, add the following code before the end statement of the start function:
readFromTable();
Although you could have assigned the readFromTable function directly to the onConstructionFunction property, you are advised to retain the start function as a separate unit of logic in case you later decide to add other code that runs before the web page is rendered.
Retain the commented code in the start function in case you need to test the web page without accessing the database. You can use the comment and uncomment capability of the Rich UI editor to quickly switch from the function call to the prototype data and back again.
The updateAll function receives an array of paymentRec records from the dedicated service. The function is called in the following ways:
The recordAdded function receives the record that was sent to and returned by the service function addPayment.
The recordRevised function receives the record that was sent to and returned by the service function addPayment.
In the next lesson, you will complete the code for the Rich UI handler.