00000000
Table of Contents
Video overview of the addon
Master-Detail Tables add-on
What does this add-on do and when is it useful?
Master-Detail Tables is an add-on for wpDataTables that allows you and your site visitors to see all desired details for each row with a simple click. Many users today have tables with a large number of columns and data. However, when such tables are placed on a website, they often disrupt the visual appearance of the page. Until now, the only solution was to hide certain columns or completely modify the table to fit the page. But what if you need all those columns and data, and you can’t hide anything because you want your users to have all the information? Don’t worry, there is now a solution for that.
The Master-Detail Tables add-on allows you to hide less important data from the table on the frontend, while still giving users the option to view all the information, either in a non-tabular view or now also in a special tabular display by simply clicking on the desired row. This way, you don’t have to delete any columns; you can simply hide them visually and display all the information when needed. This scenario illustrates a common use of the Master-detail functionality in practice. However, please note that within the details, you can also display data from columns that are visible on the frontend, i.e., columns that have not been previously hidden. This add-on provides you with the flexibility to creatively adapt it to your needs and the needs of your users.
Further in the text, it will be explained how you can easily access the desired details by simply clicking on a specific row or button, and how to use the Master-Detail add-on yourself.
Installing and activating Master-Detail Tables add-on
How to install the addon?
Installing the Master-Detail Tables addon is a quite straightforward process if you have some experience with WordPress plugins. There are 2 possible ways of uploading it to the WordPress site:
Go to your WordPress admin panel, open the “Plugins” page, then click “Add new”, choose “upload” and then browse to the ZIP file that you’ve downloaded from our store.
Go to our store, login with the credentials you received via e-mail when you purchased the plugin, download the plugin and extract the ZIP file that you’ve downloaded. Once you’ve done that open your WordPress installation through FTP, browse to wp-content/plugins, and upload the extracted folder there.
Once you’ve uploaded the plugin using one of these 2 scenarios, you should see the Master-Detail Tables add-on in your plugins list. Just click “activate”, and you’re good to go!
Using the Master-Detail Tables addon
How to enable the addon?
What you need to do first is to create wpdatatables from Table wizard. To begin with, we will create a non-editable table from this excel file. If you encounter any issues in this step while creating the table, simply follow the instructions from Creating Tables in WordPress from Excel.
When you have created a table with all the necessary columns, you can immediately select some columns that disrupt the visual appearance of the table and hide them. Don’t worry about losing the data contained in the hidden columns, because this is where the Master-Detail add-on comes into play, allowing you to provide users with that information by simply clicking on the row for which you want to see more details. You can also display data from visible columns within a separate detail view in either tabular or non-tabular display. You choose the data you want to display as additional details about a row, whether they are in visible or hidden columns. See how to select the data you want to display as details.
Please note that there is a small difference in functionality between editable and non-editable tables. This difference pertains only to a slightly different way of accessing details from the table. Here, you can learn about the basic differences in functionality between editable and non-editable tables.
Next, activate the Master-Detail Tables add-on within the Installed Plugins section. After activating the Master-Detail Tables add-on you will notice a new table settings tab called Master-Detail Settings on the table configuration page. When you click on it you will see the option “Master-Detail”.
In order to try out how the Master-Detail add-on works, please enable the “Master-Detail” option and you will see several new options.
Master-Detail options
How to use Master-Detail options?
1. Open details on – Choose the action that will enable displaying the details of a specific row – If the “Row click” is selected, users will be able to access details for a row by clicking on it. If the “Button click” is selected, a new column will be added to the table, where each row will get a button opening the details for it.
2. Show details in – Choose how your details will be opened – If the “Popup” option is selected, the details for the selected row will appear in a popup dialog on the same page. If you choose one of the “Post” or “Page” options, users will be redirected to the selected post or page (depending on what you chose in this step), which will be displayed in the current or a separate tab based on the settings you choose in the next option (4). This way, the post or page will open as a filled template with the actual data from the table. Please note that you must first create the post or page template and fill it with placeholders to use it. Later, it will be explained how to create a template.
3. A. Popup Title – Choose a title for the popup with row details. If you leave the field blank, the default title will be “Row details” (In our example we will call it Car description:)
3.B. Template page – This option is displayed if, in the previous step (Step 2 “Show details in”), you chose to display the details on a page or post. In this step, select the appropriate template you have previously created in WordPress. This can be a post or a page, depending on the format in which you want the row details to open. Creating a template works by creating a page or post that you fill with variable and non-variable parts. The visual design, details, sections, and complexity of the page are up to your imagination. There are many ways you can create this template. The variable parts are inserted into the template as placeholders, which will later be replaced by the actual data of the row when a specific row in the table is clicked. To ensure the placeholder is replaced with the correct values, insert it into the template in the following format: %originheader%. The placeholder is defined by placing the original column name between the %% signs. This ensures that the placeholder is replaced with the specific data from the exact column corresponding to the row for which you need additional details. Read more detailed instructions on creating templates later in the text.
4. Link target attribute – This option is unchecked by default. In that case, the row details will be displayed on a post/page that will open in a separate tab. If you check this option, the page or post with the row details will open in the same tab you are currently on.
5. Send details over – The POST method is chosen by default. It sends details associated with the Table ID and the Column ID from the selected/clicked row.
Limitation: With the POST method, the column placeholder values on your “Template Page/Post” will only render when the user is redirected by clicking/selecting the row from the table.
Directly visiting the URL of the “more details Page” or “Post” will only show empty column placeholders.
If you change this to the “GET” method, the details data associated with the table ID and the chosen column ID from the selected row will be conveyed through GET parameters, making the information accessible via the unique URL. In other words, this allows you to have a unique URL for each record/row in the table. This URL can be visited directly, and it will render the column placeholder values without having to click the row or button from the Table.
Please note: If you choose the “GET” method, make sure to set your chosen “Parent/Child Table column Name”.
If you leave that option blank, you will see an error if you click a row from the Table and the Template Page won’t load/redirect.
6. Send table data – This option appears only if, in the previous step (5) “Send details over,” we selected to send data via a GET parameter. “Send table data” gives you the flexibility to choose the table data you want to send. Within this option, there are three possible choices:
- Send Parent Table Row Data,
- Send Child Table Row Data,
- Send Child Table Data.
Depending on which of the three options within this feature you choose, you will be able to send detailed information in a non-tabular or tabular view. The first and second options allow you to send detailed information from the rows of the parent/existing table or the row details specifically from the child table. The third option within this feature allows you to send the entire dataset from the child table in a separate tabular view on the post or page.
We will now explain each of these three options in detail, along with examples.
Send Parent Table Row Data
6.A. Send Parent Table Row Data – This option allows you to generate desired details in a non-tabular view for the selected row of this parent table by simply clicking on the desired row or button. The option becomes visible only after selecting to send via the GET parameter in step five. The essence of this option is that only the parent table ID and the details of a specific row, in the format you previously defined in the template (Instructions on how to create a custom template), are sent via GET parameters. Sending data via GET parameters allows you to access the details of any row at any time and from anywhere, without needing to have the entire table in front of you. This way, you can directly access the details of a specific row through a URL, instead of searching for and clicking on the specific row within the table. This option is extremely useful for efficient data access and simplifies working with large tables. Pay attention to the next option “Parent Table Column Name,” where you need to select a column with unique values (e.g., WDT_ID in Manual tables) based on which placeholders in the template will display details of the exact table, column, and row.
It’s best to demonstrate the use of this option with an example. First, you need to create wpDataTables from the Table wizard. Let’s start by creating a manual table by importing this Excel file. As you can see, this table has a large number of different columns. In this specific example, we followed the steps below:
- Create a data table by importing data from a data source using this Excel file. If you encounter any difficulties in this step, read the instructions here.
- Hide all less important columns. The columns we kept visible are: “Make,” “Model,” “Model version (description) years,” “Wheel base (mm),” “Price”.
- Configure the visibility of each column in the details page in the column list.
- Enable master-detail functionality.
- In the “Open details on” option, choose to display row details by clicking on the button. You will see a new Master-detail column created called Details which is filled with a predefined value “More details” link.
- In the “Show details in” option, choose to display row details on a page.
- In the “Template page” option, insert the template you created earlier. (Instructions on how to create a custom template)
- Leave the “Link target attribute” option in its default state so that the details page is displayed in a separate tab.
- Enable the “Send details over” GET parameter.
- In the “Send Table data” option, choose “Send Parent Table Row Data.”
- For the “Parent Table Column Name,” use the wdt_ID column as the column with unique values.
After following the steps mentioned above, you will get the following table. Click on the “More Details” button in the column of the row for which you want to see more information. In the table below, you can see how the details page opens and what details it contains. Since we previously selected the option to send details via GET parameters, you can copy the URL of the details page and access it anytime and from anywhere.
Send Child Table Row Data
6.B. Send Child Table Row Data – This option allows you to connect two tables so that by clicking on a row in the parent table, you can easily access more detailed information from the child table. This eliminates the need to create tables with many different columns and entries to gather all necessary information about any item. This option works by allowing you to send row details specifically from the child table. For this option to function correctly, you need two tables, a parent and a child, which are interconnected by a common UNIQUE ID column. Within the master detail functionality, in the “Child Tables” option, select the child table whose data you want to link with the chosen parent table. Establish the link by selecting unique columns with corresponding unique values in the “Parent Table Column Name” and “Child Table Column Name” options. Create a template beforehand that will contain placeholders from the child table, which will be displayed and replaced with actual data from the child table when you click on the row in the parent table to which this information pertains. This way, you get the ability to see detailed information from the parent table row, in a non-tabular view, which is stored in the child table linked to the parent table by a unique ID column.
Note: This will only be handled as a “One-to-One” relation. If you have multiple rows with the same ID in the “Parent Table Column Name” of the selected child table; in that case, only the first row matching the chosen ID will be rendered, and any other ‘duplicate ID rows’ will be ignored. That is why we recommended using unique values for the relation columns earlier (both parent and child columns).
It’s best to demonstrate the use of this option with an example. What you need to do first is to create wpDataTables using the Table Wizard. Let’s start by creating manual tables by importing Excel files. You’ll need one parent table and one child table, which we will link using a common unique ID column. Let’s go through the steps together:
- Create a parent table by importing this Excel file. If you encounter any difficulties in this step, read the instructions here.
- Create a child table by importing this Excel file. If you encounter any difficulties in this step, read the instructions here.
- Enable master-detail functionality within the parent table.
- In the “Open details on” option, choose to display row details by clicking on the row.
- In the “Show details in” option, choose to display row details on a page.
- In the “Template page” option, insert the template you created earlier. Note that the template should contain only placeholders that will be replaced with actual values from the child table. (Instructions on how to create a custom template.)
- Leave the “Link target attribute” option in its default state so that the details page is displayed in a separate tab.
- Enable the “Send details over” GET parameter.
- In the “Send Table data” option, choose “Send Child Table Row Data”.
- For the “Parent Table Column Name” and “Child Table Column Name,” use the wdt_ID columns as the columns with unique values that match.
In this way, we have created two tables where one is subordinate to the other and provides more detailed descriptions of its rows. By clicking on the parent table below, observe how and which details open on the details page. You will notice that the page offers a detailed description of universities based on data stored in the child table. Since we previously selected the option to send details via GET parameters, you can copy the URL of the details page and access it anytime and from anywhere.
wdt_ID | wdt_created_by | wdt_created_at | wdt_last_edited_by | wdt_last_edited_at | FacultyID | FacultyName | Location | EstablishedYear | StudentCount | ProgramsOffered |
---|