How can I display the number of rows displayed, both sorted and not sorted

How can I display the number of rows displayed, both sorted and not sorted

magmomagmo Posts: 6Questions: 3Answers: 0

I wonder if its possible to display the number of rows displayed both without sorting and sorting? I wanted to show this in a span tagg using this custom script but that only display the number of rows unfiltered.

$(document).ready(function() {
  var table = $('#schedule').DataTable();
  var info = table.page.info();
  document.getElementById("tag").innerHTML = info.recordsDisplay;
});

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 10,723Questions: 25Answers: 2,449

    display the number of rows displayed both without sorting and sorting?

    Do you mean filtered?

    The page.info() API provides many values including this:

    recordsDisplay - Data set length once the current search criteria has been applied.

    Kevin

  • magmomagmo Posts: 6Questions: 3Answers: 0

    Yes I mean filtered, but that does not work. I already use that property and it still display the total number of rows even after filtering

  • kthorngrenkthorngren Posts: 10,723Questions: 25Answers: 2,449
    Answer ✓

    Is the problem that the values aren't updated when searching? I would put that code into the draw event so it updates each time the table is drawn.

    Kevin

  • magmomagmo Posts: 6Questions: 3Answers: 0

    @kthorngren Thanks, that did the trick!

Sign In or Register to comment.