How do I show row details while still being able to reload/redraw in intervals?

How do I show row details while still being able to reload/redraw in intervals?

FyodFyod Posts: 3Questions: 1Answers: 0

I am using the example in the Row details documentation (https://datatables.net/examples/server_side/row_details.html).
Everything works, however I also have a periodic draw:

setInterval(function() {
    partsTable.draw(false);
}, 10000);

and this draw causes the details to be closed upon redraw, even though I am using the same code as in the example to keep track of row_ID.

partsTable.on('draw', function () {
     $('[data-toggle="popover"]').popover();
     $.each( detailRows, function (i, id) {
          $('#'+id).find('td.details-control').trigger('click');
          console.log(id);
    });
});

I'm unsure if this is caused by all code being inside $(document).ready(function() { }).

Any help is appreciated! Cheers!

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • FyodFyod Posts: 3Questions: 1Answers: 0
    edited December 2020

    Live table here [deleted]
    You can see the details by clicking in the <td> around the thumbnail.

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    One question, why do you need a periodic draw? It's not collecting new data, it's just drawing the table again. Is the draw necessary to your flow?

    Colin

  • FyodFyod Posts: 3Questions: 1Answers: 0

    Hi Colin,
    yes, data will soon be added periodically.
    I found the mistake. I added details-control to two tds [0,1]. This I guess caused the trigger to double click (closed on draw, one click open, second click close), so it always closed.
    Is there a way I can remove the IP from my last comment?
    Cheers!

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    Done, and glad all sorted,

    Colin

This discussion has been closed.