Tutorial - Master - Detail PDF
Tutorial - Master - Detail PDF
Tutorial - Master - Detail PDF
Tutorial - Master/Detail
In this tutorial we will show you how to setup Master/Detail table view in PHPMaker. We will use the demo database for demonstration.
In the demo, there are two tables called "orders" and "orderdetails". We will set up the master/detail relation between these two tables.
1. Loading PHPMaker
Select either the master or detail table in the Database tree view (the left pane). In this example, we choose the master table - "orders" table.
The Table Setup page is displayed in the right pane.
Then in [Master/Detail] panel at the bottom right corner of the page, click [Modify...] to bring up the visual master/detail relationship editor.
Drag the detail table from the table list on the left to the diagram on the right.
Then create a relationship between them by dragging from the master field (key field in master table) to the detail field (foreign key field
in the detail table).
If there are more linked field, repeat the step until all the relationships are setup. In this tutorial, we only have one detail field
(`orderdetails`.`OrderID`) and one master field (`orders`.`OrderID`).
PHPMaker supports multiple master/detail, if the table has other master tables or detail tables, just repeat above process. In this example, we
have only one master/detail relationship, so we click [OK] to confirm. The master/detail relationship is setup.
If you want referential integrity, you can enable Referential Integrity, Cascade Delete and/or Cascade Update, see Table Setup ->
Master/Detail for detail.
If you want to enable Master/Detail-Add, Master/Detail-Edit and/or Master/Detail-View, enable them for the detail table in the Table
Setup page:
If the master table has more than one detail tables, you can choose Multiple detail tables. By default each detail table occupies a column in
the main table of the List page, if Multiple detail tables is enabled, the columns will be combined as one.
If you have the Preview extension (for registered users only) and want to enable detail record preview by Ajax, you can click Tools -> Extensions
to enable it. Also see Third-Party Tools.
Enable the extension and then click the Advanced tab to set your settings for each table:
Notes
1. The Preview extension works best when the number of the fields and number of records are not too many so the size of the
preview area will not be too large. Otherwise the preview area may exceed the browser area and therefore the detail records cannot
be viewed completely at a glance.
2. If PreviewRow is enabled, the individual detail table columns will become hidden.
Click the [Generate PHP] icon to go to the [Generate] tab, click the [Generate] button. PHPMaker will generate the required PHP scripts
automatically.
Click on the link to the "orders" table, there will be a new column for the "orderdetails " table. Click on the "orderdetails" button to access the
order details for the selected record. Click the down arrow button and then click Master/Detail View, Master/Detail Edit or Master/Detail
Copy to view/edit/copy and selected record and its detail records.
If you have enabled Preview extension and enable PreviewOverlay, move your mouse cursor over the "orderdetails" button and you'll see
detail records preview:
If you have enabled Preview extension and enable PreviewRow, click the [+] button in the row and and you'll see the preview row:
Click the Master/Detail View link/button, the View page of the master table with a detail table grid of the detail table will be shown.
Click the Master/Detail Edit link/button, the Edit page of the master table with a detail table grid of the detail table will be shown.
Click the Master/Detail Copy link/button, the Add page (in Copy mode) of the master table with a detail table grid of the detail table will be
shown.
Click the Add orders/orderdetails button in the paging section, the Add page of the master table with a detail table grid of the detail table will
be shown.
In Master/Detail-Add/Copy/Edit mode, you can click Add Blank Row or Delete button to add or delete rows without refreshing the page. Note
this feature is implemented by JavaScript.