tablesorter icon indicating copy to clipboard operation
tablesorter copied to clipboard

data-math-filter returns no results when given a valid css selector

Open du8die opened this issue 3 years ago • 1 comments

I have a conditionally formatted table - the categories of conditional formatting are indicated in a data-color attribute on the data cell.

In the footer, I have several rows that summarize the values of the conditional formatting. The footer cells are decorated with data-math-filter="[data-color='color1']". The console is reporting "No Elements Found".

<table>
  <thead>
    <tr>
      <th>Column 1</th>
      <th>Column 2</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td data-color='red' style='background-color:red'>
        3
      </td>
      <td data-color='blue' style='background-color:blue'>
        7
      </td>
    </tr>
    <tr>
      <td data-color='green' style='background-color:green'>
        6
      </td>
      <td data-color='red' style='background-color:red'>
        4
      </td>
  </tbody>
  <tfoot>
    <tr>
      <td data-math-filter='[data-color="red"]' data-math='col-sum'></td>
      <td data-math-filter='[data-color="red"]' data-math='col-sum'></td>
    </tr>
    <tr>
      <td data-math-filter='[data-color="green"]' data-math='col-sum'></td>
      <td data-math-filter='[data-color="green"]' data-math='col-sum'></td>
    </tr>
    <tr>
      <td data-math-filter='[data-color="blue"]' data-math='col-sum'></td>
      <td data-math-filter='[data-color="blue"]' style=' data-math='col-sum'></td>
    </tr>
  </tfoot>
</table>

My reading of the docs leads me to believe that the math function will filter for the data-elements - but it doesn't seem to work. I've tried a bunch of different CSS filters - nothing seems to work.

What am I doing wrong?

du8die avatar Apr 04 '22 14:04 du8die

Hi @du8die!

Oops, I asked in your Stack Overflow question - I don't remember what data-math-filter does. And also style=' in the last td is probably breaking stuff.

Mottie avatar Apr 05 '22 01:04 Mottie