Not seeing the 'childRow.dt' event triggered.

Not seeing the 'childRow.dt' event triggered.

michael_657michael_657 Posts: 2Questions: 1Answers: 0

Link to test case: https://live.datatables.net/dehonimi
Description of problem: Following the example provided on "https://datatables.net/reference/event/childRow" for handling the 'childRow.dt' event doesn't show any output.

The event doesn't trigger the handler regardless if it's applied before or after table initialization. Listening on either 'childRow' or 'childRow.dt' makes no difference and neither does using a static data set or AJAX for table data. I've also tried adding and removing a row manually afterwards with DtTable.row.add() and DtTable.row().remove().

Am I doing something wrong or is this event deprecated or perhaps just not working in the latest version of DataTables?

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 22,325Questions: 26Answers: 5,134
    Answer ✓

    I believe this event is used when using child detail rows like this example. Open the console of the example and paste this code:

    $('#example').DataTable().on('childRow.dt', function (e, show, row) {
        console.log((show ? 'Showing ' : 'Hiding ') + 'row ' + row.index());
    });
    

    Open and close a child detail row to see the event being fired.

    I don't see where you have child detail rows configured in your test case. Please provide details of what you are wanting to do so we can suggest the event(s) to look at.

    Kevin

  • michael_657michael_657 Posts: 2Questions: 1Answers: 0

    Ah, I misunderstood it then. Was thinking it was related to table rows (tbody > tr) being added or removed.

    Was looking into ways to prevent duplicate data from being entered. Seemed easier to add a custom filter somehow on an event handler than to build a plugin. For now I'm just checking the data externally wherever I add new rows.

  • allanallan Posts: 65,339Questions: 1Answers: 10,838 Site admin

    Yes, checking the data before putting it into the DataTable would be the way to do it. There isn't any internal deduplication option I'm afraid.

    Allan

Sign In or Register to comment.