Question about api.column().data().filter().count(): help needed
Question about api.column().data().filter().count(): help needed
Gargiucn
Posts: 109Questions: 30Answers: 0
in DataTables
In the following script:
let testo2ab = api
.column( 14 )
.data()
.filter( function ( value, index ) {
return value == 0 ? true : false;
} )
.count();
if ( testo2ab != 0 ) {
api.column(4).visible( false );
}
count() is executed for all rows from the database.
is it possible to use a filter to be able to count only rows that olso have a certain value (ex: id = 1)?
I thank you for your support,
Giuseppe
This question has an accepted answers - jump to answer
Answers
I tried your code snippet here:
https://live.datatables.net/fujuputi/1/edit
Adjusted like this to work with the data in the table:
The code works and results in only 4 Directors found. Maybe I'm not understanding your question.
Please provide a link to your page or a test case, update mine if you want, replicating the issue so we can help debug.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
Referring to your example, it's as if I would like to find the number of Directors who have offices in London...
Giuseppe
Right. Instead of using
filter()
userows()
with arow-selector
as a function to select the rows based on values in multiple columns. Updated example:https://live.datatables.net/fujuputi/2/edit
Kevin
Actually I don't need it because it still respects the selection filter I applied on the table.
Thanks for the help.
Giuseppe
Actually I don't need it because it still respects the selection filter I applied on the table.
Thanks for the help.
Giuseppe
Sorry, I wrote before I saw your reply.
It is very useful your example and I will need it.
Thanks for the help.
Giuseppe