Sumber : HKVSTORE - PHP MAKER
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`).
If you want referential integrity, you can enable Referential Integrity, Cacade Delete and/or Cascade Update, see Table Setup -> Master/Detail for detail.
Notes
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/buttonk, 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.
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.
Fields in Table "orders"
Fields in Table "orderdetails"
Steps to Setup Master/Detail Records
1. Loading PHPMaker
Open PHPMaker and connect to the demo database.
2. Setting up Master/Detail Relationship
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 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/setail relationship is setup.
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
- 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.
- If PreviewRow is enabled, the individual detail table columns will become hidden.
3. PHP Script Generation
Click the [Generate PHP] icon to go to the [Generate] tab, click the [Generate] button. PHPMaker will generate the required PHP scripts automatically.
4. Running the PHP Application
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/buttonk, 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/ordertails 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 wiithout refreshing the page. Note this feature is implemented by JavaScript.
0 komentar:
Posting Komentar
Masukan Komentar yang sesuai jika tidak, maka akan dianggap spam.