I have added date filter to the table. Now I want to count the number of rows in the table.
I have added date filter to the table. Now I want to count the number of rows in the table.
shekhard
Posts: 19Questions: 5Answers: 0
This discussion has been closed.
Answers
I think you are asking about the
recordsDisplay
property of thepage.info()
API.Kevin
table.rows().every(function(){
}) loops through all rows. But I want it to loop through only the rows in the table after the filter is applied.
Can I add the count value to table.rows() so that it only loops through that many rows not all rows
The
rows()
API documents how to control the rows that are looped through. Theselector-modifier
of{search:'applied'}
is what you are looking for.Kevin
Can you give me a working example
Like here
I want to print only the first 8 rows. How will I do that.
Got the answer
table.rows({page:'current'}).every(function () {
console.log(this.data);
}
Your answer was correct. Had to use a selector modifier.
You probably wouldn't be able to use
rows().every()
for this particular case. Use a for loop and in the for loop userow()
, singular, to get the row. Therow-selector
documents the options for selecting the particular row. However simply passing the for loop variable might not be enough. You may need to use the jQuery selector of:eq()
.The specific answer for your case depends on your table data and what specifically you need. If you want an example for your case please build a simple test case so we can provide a better answer.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin