In this section: How to: |
Another option for updating the fannames data source is to create a form that includes a read/write grid. A read/write grid enables you to display the contents of a data source stack in a grid and to make changes directly to the stack. There are two read/write grids available in the MDE – an ActiveX Grid and a JS (JavaScript) Grid. This tutorial uses the ActiveX Grid, however, most of the information given here also applies to the JS Grid. For more information about the two read/write grids, refer to Developing and Using Controls in the Developing WebFOCUS Maintain Applications manual.
The following procedure enables you to create a form containing a read/write grid.
WebFOCUS Maintain opens the Control Columns dialog box, where you define the contents of your grid.
Note: Make sure you did not select AddFanStack.
The Control Columns dialog box now displays the columns in the stack GetFanStack.
You can change the appearance of any of these columns by opening the Grid Column dialog box. For example, suppose you want to change the header titles for the FIRSTNAME and LASTNAME fields so that they read First and Last.
You can also change the width, justification, font, and color if you wish.
Your form will resemble the following:
When you copied the UpdateButton from the Update_Form, the deep copy imported the logic from the UpdateFan case. This logic updates only one field in a stack at a time. The following modification to the logic behind the Update button enables you to update the entire GetFanStack at once.
Case UpdateFan Update fannames.CUSTOMER.LASTNAME fannames.CUSTOMER.FIRSTNAME fannames.CUSTOMER.COMPANY fannames.CUSTOMER.ADDRESS fannames.CUSTOMER.CITY fannames.CUSTOMER.STATE fannames.CUSTOMER.ZIP fannames.CUSTOMER.PHONE fannames.CUSTOMER.EMAIL fannames.CUSTOMER.TITLE from GetFanStack(GetFanStack.FocIndex) ; EndCase
Case GridUpdate For all Update fannames.CUSTOMER.LASTNAME fannames.CUSTOMER.FIRSTNAME fannames.CUSTOMER.COMPANY fannames.CUSTOMER.ADDRESS fannames.CUSTOMER.CITY fannames.CUSTOMER.STATE fannames.CUSTOMER.ZIP fannames.CUSTOMER.PHONE fannames.CUSTOMER.EMAIL fannames.CUSTOMER.TITLE from GetFanStack(1); EndCase
The Update button on the Grid_Update form will now update the entire fannames data source, allowing you to make multiple changes to the read/write grid and update with one click.
Try running your application and accessing the Grid_Form from the ShowFan form.
Change some of the values in the grid and click the Update button. You should see the changes you made in the grid appear on ShowForm. Note that using the read/write grid to update extremely large data sources is not recommended. For detailed information on grid functionality, see Developing and Using Controls in the Developing WebFOCUS Maintain Applications manual.
WebFOCUS |