Using the new Master Detail Dynamic Action

Although there’s been almost 2 months since FOEX v2.2.0 was released, we’ve been pleasantly surprised by the amount of the feedback gathered from our users.

Probably one of the most expected features in v2.2.0 was our new master detail dynamic action. This action can be used to link 6 types of components: Forms, Grids, Tree Grids, List view, Charts and Big Number (one of the new components which was included in the v2.2.0 release). Getting back to our master detail dynamic action, some of you may wonder how to set it up correctly.

Below you’ll see a brief example where we configure a master detail relation between the 2 grids: Countries and Cities. First, let me show you the end result and how your master detail dynamic action should work:

foex-master-detail-example

FOEX v2.2 – Master Detail Dynamic Action example

 

Defining the regions

To setup this dynamic action we will define our master by listening to the “Before Render” event of our master grid region. In our example the Countries grid region.

foex-master-detail-setup1

 

The Master Region is defined by the selection within the “When” section of the Dynamic Action as seen below:

foex-master-detail-setup1a

 

The Detail Region is defined within the Action and the “Affected Elements”. In our case we define the Cities region grid as a detail region:

foex-master-detail-setup1b

 

Setting up the relation between the 2 regions

Next we will define our action and in the settings we will choose the columns from our master and detail grid SQL queries which define the relation i.e. the foreign key relationship.

Note: we can optionally set page item(s) with the corresponding value of the master column(s) e.g.

foex-master-detail-setup2

 

Options

There are a number of settings which can enabled here. In our example we’ve selected the first, third and last one, but I’ll briefly explain what each of them does below:

foex-master-detail-setup3

The options selected for this example:

  • Alert on Unsaved Changes – check this option to notify the user to save or discard changes before changing row selection or before refreshing the master or detail region when changes are pending.
  • Detail Automatic Saving – check this option to automatically save the Detail region when the Master region is saved. When set to “Yes” the detail’s Save button will be hidden automatically. Leave it unchecked to use the detail region’s own Save button for performing the saving at the user’s request. (Note: you must ensure that your detail regions have a button defined with “SQL Update” action for this feature to work.)
  • Restrict Detail Data if No Selection – do not show any data in the detail region if the master record has not been selected/loaded. If left unchecked then no filter will be applied to the detail data and all data in the detail query will be shown when no selection has been made on the master.

 

The other options available:

  • Refresh Detail after Master Save – check this option to refresh the detail region after the master record is saved.
  • Auto Focus Detail on Master Selection – check this option to focus on the detail region when the master record is selected. (Note: this may have an undesired effect if you automatically select the first row of your master on load e.g. using a tab panel layout for master/detail.)
  • Refresh Detail LOV Columns on Master Select – check this option to refresh the list of LOV columns defined for the detail region on master row select
  • Refresh Detail LOV Columns on Master Save – check this option to refresh the list of LOV columns defined for the detail region on master row save
  • Refresh Master LOV Columns on Master Save – check this option to refresh the list of LOV columns defined for the master region on master row save
  • Refresh Master LOV Columns on Detail Save – check this option to refresh the list of LOV columns defined for the master region on detail row save

 

Selection Behaviour

Next we can control how the master and detail regions behave after saving and loading. For example, we may want to select the first row of the master to populate the detail grid automatically.

foex-master-detail-setup4

Select the desired selection action to perform after the master/detail region is loaded. As a brief overview of the options available, you should select:

  • “Retain Current Selection” to retain the current selection across refresh. If the selected row is not found in the results, or no row was selected before refreshing, then no row will be selected.
  • “Select First Record” to always select the first row after refresh.
  • “Select First Record if No Selection” to retain the current selection across refresh. If the selected row is not found in the results, or no row was selected before refreshing, then the first row will be selected.
  • “No Selection” to have no rows selected after refreshing. If a row was selected prior to refreshing it will be deselected.

 

Button Management

Optionally, we can manage additional buttons on our master/detail regions by adding a comma delimited list of button static ID’s e.g.

foex-master-detail-setup5

 

Unsaved Changes

Lastly, we can add a custom notification for when a user tries to refresh the region, change rows, leave a page which has unsaved changes. Here’s the notification text we used in our example, and below it you’ll see the message that pops up when changes made into a region are not saved and the user tries to select another line.

foex-master-detail-setup6

 

foex-master-detail-example-unsaved-changes

FOEX v2.2 – Unsaved Changes example

 

Summary

In this example we showed you a simple master detail dynamic action setup between 2 grids. You can create multi-level relationships using this plugin. Taking our example one step further, you could easily create a 3rd level showing all the suburbs within a city and optionally a 4th level showing all the streets within a suburb.

 

If you don’t have a FOEX account yet, sign up for a free trial and see why it is a great tool for developing large-scale web applications!

Add your comment

Your email address will not be published. Required fields are marked *