Master Detail Tables

Master Detail Tables

synaqvisynaqvi Posts: 11Questions: 4Answers: 0
edited August 2021 in DataTables 1.10

Hi

I am new to Datatables and trying to create two tables (i.e. Master and Detail). Detail table rows should be based on the ID in the Master table. I am following the tutorial https://datatables.net/blog/2016-03-25 and everything working fine while following the same from end to end. Please also note that I am not using DataTables but not DataEditor and hence, I skipped the DataEditor parts. I will be using the same approach down the road.

The issue is that my Master table is being populated on page load through PHP script without any issues. When I select any row in the Master table, I need to call a PHP script that runs a query to select all the records from Detail table based on the ID from Master table I passed and return the set of records.

Afterwards, I want to show all the returned records in the Detail table using AJAX.

Prompt support as well as a working example (if possible) would be highly appreciated.
Thanks in advance.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,139Questions: 26Answers: 4,735

    Sorry but I'm confused. Have you implemented this and it doesn't work or are you asking about how to implement without the Editor portion?

    There is a working example in the blog you linked to. Do you have questions about the example in the blog?

    The best way for us to help is for you to provide a link to your page or a test case showing the issues you are having.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • synaqvisynaqvi Posts: 11Questions: 4Answers: 0
    edited August 2021

    Thanks @kthorngren for your prompt response. Let me keep it simple and straight while excluding the extra information.

    Let's say:

    1. I have a DataTable called Master and another DataTable called Detail.
    2. When I click a row in Master DataTable, I will pick up the primary key (a column) of that row.
    3. Pass it to my PHP script.
    4. Run a query to select related records to that specific primary key that I passed earlier.
    5. Return the recordset.
    6. Clear my Detail DataTable.
    7. Populate my Detail DataTable with that specific returned recordset.

    And I want to use AJAX rather than reloading the page. Plus, I only want to use the DataTable and no DataEditor at all.
    Makes sense?

  • kthorngrenkthorngren Posts: 20,139Questions: 26Answers: 4,735
    Answer ✓

    I remembered putting this simple example together based on the blog example:
    http://live.datatables.net/biliniyu/1/edit

    Basically you can use the example in the blog and ignore the Editor configs. Both the blog and my example use Ajax and don't reload the page.

    Do you have specific questions about the blog or my example? I'm not sure what else to provide to help you.

    Kevin

  • synaqvisynaqvi Posts: 11Questions: 4Answers: 0

    Thanks @kthorngren. Your example is more close to what I needed.

Sign In or Register to comment.