Okay
  Public Ticket #3844357
Displaying both parent table parameters and child table in same page
Open

Comments

  • Jeremy Tran started the conversation

    Hello, 

    I'm trying to display the parent table parameters as a child table in the same page. Is this possible? 

    If I set to "Send parent table row data", then I can view the parent parameters but not the child table.

    If I set to "Sed child table data", then I can view the child table and not the parent parameters.

    This is what I have in the master details page:

    %First_Name% %Last_Name%

    Company: %Company%

    %item_id%

    Email: %Email%

    Phone: %Phone%

    LinkedIn: %LinkedIn_Profile%

    Stage: %Stage_of_Contact%

    Contact Type: %Contact_Type%

    Label: %Label%

    Notes: %Notes%

    Contact Owner: %Contact_Owner%

    Owner Code: %Owner_Code%

    Owner Email: %Owner_Email%

    Entry Date: %Entry_Date%

    %wpdatatables_md_child_table%


  •  1,887
    Miloš replied

    Hi Jeremy,

    If I understand, you would like to 'combine' having column placeholders from a table render the cell values from the selected row ID on the same Page/through the same Table, where you would also render the full child table?

     

    We don't have a valid solution as 'ouf of the box' for a scenario like this while only using one table.

     For each table, we can only choose to set it up either as 'pass the Child table data' to the Template Page or render the column placeholders to the Template Page/Post, but we can't combine both with the same "Parent table". 

     

     You can try a workaround, by making a duplicate table from the Parent Table. 

     Then, in this duplicated Parent Table - You can change the Master-Detail configuration for it, and here you can change it from "pass Child table", to "pass parent table placeholders". Choose the same Template Page URL, and this could be as a 'workaround solution'. 

     Just note, if you use a Manual table, be careful what you choose in the 'duplicate option'.

     

    5514277976.png

    For manual tables, I would strongly advise leaving this option enabled:

    1081620257.png

    This way, the plugin will create a new table in the database, so changes in the new table will not affect the original table.

     

    Basically, any option in a duplicate table will be 'mirrored', even the Master-Detail options; 

    So if this is a Manual table - you will have to check that duplicate option to have them completely 'separate from each other', if that makes sense.

     

    If there is a lot of row editing in the table, I realise this will involve more manual work to maintain both tables, so that is a downside of this method. 

     The only way to 'make it easier for editing' is, you can use a Spreadsheet, so for example when you edit the Table A,  you can try to export it as CSV/Excel, then update the Table B fia file upload, or copy cells as Excel-Like Editor view, etc. 

     

     I hope that helps.

    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps and floor plans, choropleth maps and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  • Jeremy Tran replied

    Thanks Milos!

    I ended up figuring it out and wanted to share what I did for someone else who may be looking for the same.

    Here are the steps for implementing a parent-child table relationship using wpDataTables:

    Parent Table Setup
    1. Create an SQL-based parent table where each entry has a unique item_id
    2. Configure the Master-Detail settings:
      • Enable Master-Detail functionality
      • Set "Open details on" to "Row click" or "Button click" as preferred
      • Set "Show details in" to "Page"
      • Set "Send details over" to "GET"
      • Set "Send table data" to "Send Parent Table Row Data"
      • Set "Parent Table Column Name" to your unique identifier (item_id)
      • Select your template page
    Child Table Setup
    1. Create a table that contains related entries with a parent_item_id column that associates with the parent table
    2. Keep Master-Detail disabled for this table
    3. Configure Placeholders:
      • Set %VAR1% = parent_item_id
    4. Set the SQL query to include a filter:
      SELECT * FROM "your_SQL_table" WHERE parent_item_id = %VAR1%
      
    Template Page Configuration
    1. Add placeholders for parent table data using the format %ColumnName%
    2. Insert the child table with a shortcode that passes the item_id:
      [wpdatatable id=8 table_view=regular var1=%item_id%]
      

    This setup allows you to view the detailed information from the parent table and their associated interaction from the child table on a single page when clicking on an entry in the parent table.