Working with the packeting container details part
The packeting container details part not only provides a convenient way to display data, but also provides a working form that enables the user to edit and update data in the database.
You can add some finishing touches to the window as follows:
Formatting a packeting container details part  
You can change the column headings of a packeting container details part by direct-editing. Hold down the Alt key and click mouse button 1 on the column heading you want to edit.
To size the columns in the packeting container details part, select the column and then hold down mouse button 1 to drag one of the selection handles to the left or right.
To adjust the position or order of columns, select the column and then hold down mouse button 2 to drag the column to its new position.
For more information on using the packeting container details part refer to the Visual Programming User Guide.
Applying changes to the database  
You can also add push buttons to an application for saving or discarding changes that the user makes to the container details part.
1. Add two push buttons, labeled Apply and Cancel.
2. Make the following connections for the Apply push button:
a. Connect its clicked event to the apply action of the result table
b. Connect its clicked event to the commitTransaction action of the multi-row query
3. Make the following connections for the Cancel push button:
a. Connect its clicked event to the cancel action of the result table
b. Connect its clicked event to the rollbackTransaction action of the multi-row query
Be certain you make the connections in the order shown.
4. Select Test to test your visual part.
When you change the rows in the container details part and then apply the changes, VA Smalltalk performs all the SQL statements that are needed to update the rows you changed. Similarly, if you use the newRow or deleteRow actions to insert or delete rows, VA Smalltalk performs the insert and delete SQL statements also. When you use the cancel action instead, VA Smalltalk discards the changes you made.
Tip
The commitTransaction action makes the changes permanent in the database. If your application has more than one query, be certain that you perform all the apply actions for the various queries first, and perform the commitTransaction action last, since it commits all of the work for all of the transactions. Conversely, the rollbackTransaction action discards all the work for all uncommitted transactions.
The commitTransaction and rollbackTransaction actions are executed against a database connection. If your application has more than one database connection, make sure that you commit or rollback against the correct connection.
For the sample application, the update policy set in the Multi-row Query Settings window requires that users specifically commit their changes to the result table. If you edit one cell in the result table and then move on to another cell, you can still rollback your changes to the first cell until you select the Apply push button.
If the update policy for a query uses the Auto commit setting but not the Defer updates setting, then changes to the result table are committed immediately and these push buttons are not required.
 
Last modified date: 07/25/2020