Parent/Child Forms

Parent/Child Forms

Parent/Child Forms

General Information

You can use the parent/child form to represent parent/child relationships in an application. The form has a parent/child control placed where the grid resides in a Find/Browse form. This control presents a tree view in the left portion of the control, which displays a visual representation of the parent/child relationship. The right portion of the composite control displays a grid in browse mode. A movable bar separates the tree view and grid. Use it to resize either view horizontally. The grid displays the detail information for the nodes of the tree. The parent/child form uses one business view.

There are two modes available on the parent/child form. You can choose the default mode or show all details. The default mode displays the detail for all nodes at the same level in the tree. As you switch levels in the tree, the grid lines change to reflect the level you are in. If you choose to show all details, there is a one-to-one correspondence between the nodes in the tree and the grid lines. You can also load pre-expanded trees so that if you click Find the tree will display all levels instead of just loading one level of nodes at a time. If you choose this option, it shows up as an option on the right mouse menu. You can also allow multiple selects.

Use the Parent/Child form to:

  • Represent Parent/Child relationships.
  • Perform normal Find/Browse functions (including FETCH and SELECT WHERE statements) and present information in a tree format.

The following table describes toolbar functionality for this form.

Select

Standard toolbar button that comes with the form. You must add the appropriate form interconnections to provide functionality.

Find

Standard toolbar button that comes with the form

Close

Standard toolbar button that comes with the form

Add

You can add this button to the toolbar. You must also provide the functionality for the button, which typically includes a form interconnect.

Copy

You can add this button to the toolbar. You must also provide the functionality for the button.

Delete

You can add this button to the toolbar. You must also provide the functionality for the button.

OK

This button does not apply to this form type.

Cancel

This button does not apply to this form type.

Parent/Child form processing is based on the concept of a parent/child relationship between two data items either within a table or across different tables. If the parent/child relationship is within a table or business view it is an inherent relationship. If the parent/child relationship is between two different tables or business views, then the relationship is an established one.

To display explicit parent/child data, the business view underlying the parent/child form should have a parent column and a child column. When any node on the tree for the form is expanded, a fetch is performed by querying the database for all the expanded node's child records. For example:

  • Business unit 10 consists of business units 5 and 3.
  • Business unit 5 consists of business units 2 and 1.

There is an inherent parent/child relationship between business unit 10 and business units 2 and 1.

If you simply wish to display data in a hierarchical fashion, the business view does not need to have a parent column and a child column. You must develop the logic to perform a fetch when a tree node is expanded.

The Delete hyperitem will delete the currently selected node record from the table. You must delete child records if needed.

The steps involved in creating a Parent/Child form are different than other form types. To create a Parent/Child form:

  • Create the form in Form Design Aid
  • Select a Business View
  • Highlight the grid and add columns to the grid
  • Add filter fields to the form

Choose the Parent field from the business view as the filter because the tool uses this for fetches from the database

Until this point, the form setup for Parent/Child is almost identical to the setup for a Find./Browse form. From this point on, there are unique steps to complete the Parent/Child form. See Working with Controls for information about completing the Parent/Child form design.

Process Flow

Description

A Parent/Child form is used to query on a business view and represent the data in a hierarchical manner. Records can also be selected from that business view for an operation. The following sections describe the processing flow of a Parent/Child form type.

Default Flags

There are no form options flags checked by default on Parent/Child forms. The only form option flag that can have an impact for this form type is the “No Fetch on Grid Business View" flag. Checking any of the other form option flags does not have any impact on the form processing.

The Parent/Child Browse forms along with Find/Browse forms are the only forms that have the “Entry Point" property checked by default. Parent/Child forms are typically the entry points into applications. The entry point property can be unchecked by the application developer.

Dialog Initialization

  1. Initialize Thread Handling
  2. Initialize Error Handling Process
  3. Initialize Business View Columns
  4. Initialize Form Controls
  5. Initialize Grid/Tree Fields
  6. Initialize Static Text
  7. Initialize Helps
  8. Initialize Event Rules Structures
  9. Create Toolbar
  10. Load Form Interconnection data into corresponding business view columns and filter fields, if any
  11. Perform Event Rules: Dialog is Initialized
  12. Perform Event Rules: Post Dialog is Initialized
  13. If the grid option flag “Automatically Find On Entry" is checked
  14. Begin Detail Data Selection and Sequencing

Header Data Retrieval

There is no header record for Parent/Child forms.

Detail Data Selection and Sequencing

An internal structure is now created representing the data selection and data sequencing requirements specified by the user. This is then passed to the database engine to do the actual database select and sequencing. The data is then held until the data is retrieved in the next step.

The data used for selection is pulled from filter fields and QBE Columns.

  1. If the form option flag “No Fetch On Grid Business View" is unchecked
  2. Select and Sequence
  3. Begin Data Retrieval

Data Retrieval

A request is issued to the JDEKRNL, which performs the actual fetch of the data from the database. It will read one record at a time and for each record, perform the required processing. The data retrieval is performed in two different ways in the Parent/Child browse form. The fetch performed to get the first level nodes in the tree is similar to the one performed in the Find/Browse form:

Data Retrieval for the first level node in the tree

  1. Attempt to fetch a record from the database
  2. If a record is fetched
  3. Copy the data into the business view data structures
  4. Perform Event Rules: Grid Record is Fetched
  5. If the application developer has not chosen to suppress the writing of this record
  6. Copy the business view data into the grid data structures
  7. Perform Event Rules: Write Grid Line - Before
  8. Add the row to the grid and the corresponding column in Tree. The row and the corresponding tree node now exist in the control.
  9. Perform Event Rules: Write Grid Line - After
  10. Clear the data structures for reading the next record.

The previous steps occur for each record read from the database. After all records have been read:

  1. If the Parent/Child Browse form has the grid permanently hidden, then expand the header node and move the selection to the first child node under the header. This initiates the events: ‘Tree - Node Level Changed’ and ‘Tree - Node Selection Changed.’
  2. Perform Event Rules: Last Grid Record Has Been Read

The Parent/Child form also performs data retrieval whenever a particular node on the tree is expanded. However, this fetch is performed only once for each node that is expanded. If a particular node is collapsed and expanded again, then the tree and the grid are replenished from internal structures. The processing performed for node expand event is given below:

Data Retrieval for Tree Node Expand

  1. Perform Event Rules: Tree - Node is expanding
  2. Check for internal flags to see if the fetch is not suppressed. If the fetch is suppressed through the system function, Suppress Fetch on Node Expand, the processing stops here.
  3. Perform the key substitution (copying child key into parent key), that was setup in the design of the form.
  4. Attempt to fetch a record from the database
  5. If a record is fetched
  6. Copy the data into the business view data structures
  7. Perform Event Rules: Grid Record is Fetched
  8. If the application developer has not chosen to suppress the writing of this record
  9. Copy the business view data into the grid data structures
  10. Perform Event Rules: Write Grid Line - Before
  11. Add the row to the grid and the corresponding column in Tree. The row and the corresponding tree node now exist in the control.
  12. Perform Event Rules: Write Grid Line - After
  • Clear the data structures for reading the next record.
  1. Perform Event Rules: Last Grid Record Has Been Read
  2. Move the tree selection to the first child node under the expanding node. This initiates the Events: Tree - Node Level Changed and Tree - Node Selection Changed.

Closing Form

  1. Perform Event Rules: End Dialog
  2. Load Form Interconnection data from corresponding business view columns, if any
  3. Terminate Error Handling
  4. Terminate Thread Handling
  5. Terminate Helps
  6. Free all structures for form, including structures for Business View Columns, Form Controls, Grid Columns, and Event Rules.
  7. Destroy the window

Menu/Toolbar Items

Select

Select is a standard item that is automatically placed on Parent/Child Browse forms. There is no default processing for Select on Parent/Child Browse forms. It will behave as a user-defined item.

Close

Close is a standard item that is automatically placed on Parent/Child Browse forms. It closes the form.

  1. Perform Event Rules: Button Clicked
  2. Perform Event Rules: Post Button Clicked
  3. Begin Closing Form

Delete

Delete is a standard item that can be added to Parent/Child Browse forms. Similar to the Find/Browse form, the Parent/Child Browse form does the following.

  1. Perform Event Rules: Button Clicked
  2. For the selected tree node
  3. Copy the grid row data into the Business View structures
  4. Remove Suppress Delete flag
  5. Perform Event Rules: Delete Grid Rec Verify - Before
  6. If the Suppress Delete flag is not set
  7. Display Delete Confirmation dialog. If the user clicks No or Cancel the rest of this processing is skipped.
  8. Perform Event Rules: Delete Grid Rec Verify - After
  9. If the Suppress Delete flag is not set
  10. Perform Event Rules: Delete Grid Rec from DB - Before
  11. If the Suppress Delete flag is not set
  12. Delete the record in the Business View from the database.

This will not delete the child records of the node, if any, from the database. It is your responsibility to delete them from the database.

  • Delete the grid row from the grid control
  • Perform Event Rules: Delete Grid Rec from DB - After
  1. Perform Event Rules: All Grid Recs Deleted
  2. Perform Event Rules: Post Button Clicked

Find

Find is a standard item that is automatically placed on Parent/Child Browse forms. When clicked by the user, it is the signal to the runtime engine to call the database and reload the grid based on the selections in the Filter Fields and QBE columns.

  1. Perform Event Rules: Button Clicked
  2. If there no errors in any filter fields
  3. Begin Data Selection and Sequencing
  4. Perform Event Rules: Post Button Clicked

Copy

Copy is a standard item that can be added to Parent/Child Browse forms. There is no default processing for copy on Parent/Child Browse forms. They will behave as user defined items. If a form interconnection is placed on the Button Clicked event then the called form will open in copy mode.

Add

Add is a standard item that can be added to Parent/Child forms. There is no default processing for add on Parent/Child forms. They will behave as user defined items. If a form interconnection is placed on the Button Clicked event then the called form will open in add mode.

User-Defined Items

User-defined items are nonstandard items that you can add to Parent/Child forms to perform specialized processing not handled by the standard items.

  1. Perform Event Rules: Button Clicked
  2. Perform Event Rules: Post Button Clicked