Sort jQuery table with colspan or rowspan

Hi

I am using tablesorter and have problems sorting tables containing rowspan in the definition. I read the hints here Grouping rows with sorting the HTML table on the client side but the solution does not work when I have different values ​​for rowspan: once is rowspan = 3, once 4 - depends on the data taken from the database.

Do you have any other plugin that sorts even such non-standard tables, or maybe you know how to set up tablesorter so that it sorts data correctly?

Expected behavior: when a row is clicked on a column, the “belonging” to rowspan should be sorted only in this section, and all the rest should be sorted in the standard way.

Thanks in advance ,

Zbigniew

Example table code:

<html>
<body>
  <table id="misint" border=1 width="400px">
    <thead>
        <tr style="background:yellow">
            <th>Col1</th>
            <th>Col2</th>
            <th>Col3</th>
        </tr>
    </thead>
    <tbody>
        <tr>
          <td rowspan="3">1-1</td>
          <td>1-2</td>
          <td>1-3</td>
        </tr>
        <tr>
            <td>2-2</td>
            <td>2-3</td>
        </tr>
        <tr>
            <td>3-2</td>
            <td>3-3</td>
        </tr>
        <tr>
            <td>4-1</td>
            <td>4-2</td>
            <td>4-3</td>
        </tr>
        <tr>
          <td>5-1</td>
          <td rowspan="2">5-2</td>
          <td>5-3</td>
        </tr>
        <tr>
            <td>6-1</td>
            <td>6-3</td>
        </tr>
    </tbody>
  </table>

</body>
</html>
+3
source share
1 answer

You should study the functionality of the table sorter analyzer. You will need to develop your own parser that can correctly recognize the cells.

0
source

Source: https://habr.com/ru/post/1752450/


All Articles