Reload nested datatables and open shown rows - Page 2

Reload nested datatables and open shown rows

2»

Answers

  • sarthaks21sarthaks21 Posts: 41Questions: 8Answers: 0

    @kthorngren I've corrected the error mentioned above.

    http://live.datatables.net/nuhopemu/33/edit

    The output tab only displays the Table Head and Reload button. That's why I'm not able to view any error before sharing with you. Hope you don't mind.

    Kevin Bro, thanks for sticking for so long.

  • kthorngrenkthorngren Posts: 21,546Questions: 26Answers: 4,988
    Answer ✓

    Took a bit to work this out but the biggest issue is getting the proper row API. You had var _row = this; instead it needed to be var _row = childDataTable.row(this);. Note that I'm now getting the child Datatable API instance with childDataTable = $('#cl' + id).DataTable({ ... });. I also added the level 2 child Datatable init code. Here is the updated example:
    http://live.datatables.net/heqijuji/1/edit

    I see two issues:

    1. When reopened the level 2 child shows different data. I didn't look at your code to get this data.
    2. After the reload I see errors like this when clicking the level 2 child:

    runner:19 Uncaught TypeError: Cannot read property 'matterID' of undefined

    Sounds like, for both issues, the re-opened children aren't getting the correct data. I'll let you look into this :smile:

    Good job putting this together!

    Kevin

  • sarthaks21sarthaks21 Posts: 41Questions: 8Answers: 0

    Hey Kevin @kthorngren ! Thanks for the solution. I've solved the data source problem. But I'm not able to detect the reason for the 2nd issue mentioned by you above.

    When I open multiple rows and then reload, only the 1st row is showing this error the rest are working fine.

    Any idea as to why this is happening?

  • kthorngrenkthorngren Posts: 21,546Questions: 26Answers: 4,988

    For some reason the variable childTable is becoming undefined causing the error. In the click event I make sure to obtain the API for the Datatable, I added this to the click event:

                // Add event listener for opening and closing second level childdetails
                $('tbody').on('click', 'td.details-control1', function () {
                    var tr = $(this).closest('tr');
                  
                  // Get API instance of table
                  var table = $(this).closest('table');
                  childTable = (table).DataTable();
    

    Here is the updated test case:
    http://live.datatables.net/heqijuji/2/edit

    Kevin

This discussion has been closed.