Count cells with specific value and row class

Count cells with specific value and row class

epoch1epoch1 Posts: 17Questions: 8Answers: 1
edited March 2017 in DataTables 1.10

Hi all,

I am trying to find a way to count the number of cells with a particular value for selected rows (or cells with a particular class), Is this possible? Something like:

dt.rows( '.selected' )
.data()
.indexOf('cellValue')
.count()

Or where the row has a class of selected and the cell has a class of bg-success

dt.rows( '.selected' )
.cells('.bg-success')
.count()

Thanks

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,667Questions: 1Answers: 10,096 Site admin
    Answer ✓

    The first option, but with filter() rather than indexOf() is probably the way to do this.

    The other option is to use row-selector as a function and have it select only the rows of interest.

    Allan

  • epoch1epoch1 Posts: 17Questions: 8Answers: 1

    Thanks again for your help Allan, much appreciated.

This discussion has been closed.