Many-To-Many child panels

The Many-To-Many panels may be used to display child panels when the child table has a many-to-many relationship in the database. There are three tables involved in the relationship: two parents and one child.  A many-to-many panel will be generated in place of the usual child panel when any one of the parents is used to create a page.

These pages allow the generation of Many -To- Many child panels:

You can control the generation of the many-to-many panel and generate a one-to-many panel instead using the for “Select which panel to generate” application generation option. This option is availabe for all page types mentioned earlier. Child panel generation depends on both the option setting and the relationship of the child table. If there is no many-to-many relationship for the child table, a one-to-many will be generated.

How it works

Using the SouthWind sample database, the Roles and SalesRep tables both have SalesRepRoles as a child table. When an Edit Roles page is generated, it will show the SalesRep table in a many-to-many panel instead of the usual SalesRepRoles child panel.  Records will be saved in the SalesRepRoles table as usual.

 

The idea is to show both the parent tables of a Many-To-Many child table. The Many-To-Many child table stores the two foreign key values of the parents. Thus the application user can select the check box and click the save button, which will save the two pimary keys as a record in the Many-To-Many table.

The panel has two internal variables which records all the data selected/unselected so the application user does not have to save the record on pagination. These hidden variables will be used when save button is clicked.

A Many-To-Many panel has its own Save button, which can be use to save just this panel.

Selection Filter

This panel consists of a static list filter with two initial values: Show All is the default selected option, and Show Included only shows selected record or related record to the parent. In the case of an Edit Roles page, Show Included selection will show all the Sales Reps who belong to this Role.

You can go to the Properties for the actions of the filter in the Layout Editor and rename the values or set the initialize value to Show Included.

Initially the filter type is a dropdown, however you may generate a Checkbox by changing the Many-To-Many Option “Selection filter type”.