Search code examples
jquerytablesorter

Avoid Sort entire Tbody Jquery Tablesorter


I'm using Mottie Jquery tablesorter Fork.

I have this Html Structure:

  Tbody-->tr/--->th/
  tr--->Tbody
  tr
  tr
  tr


  <tr role='row'class='titulo2' id='verde".$id."'>
  <th colspan='8'><h2><i class='fas fa-balance-scale'>
  </i> Haz Seleccionado Este Juzgado y vas de primeras en el <i class='far fa-smile- 
  wink'></i></h2></th></tr><tr class='highlightgreen'><td><h5><span id ='mifav' 
  class='badge badge-Light'>sometext</span></h5></td></tr></tbody>

I'm trying to avoid to sort the entire tbody but when I do some sort the second tr inside de tbody change position like this:

enter image description here

enter image description here

Things that I've tried:

Setting no sorter classnames.

Setting specific class selector like `staticRow_class


Solution

  • I found the Answer into Mottie Documentation

    Sorting with Multiple Tbodies

    https://mottie.github.io/tablesorter/docs/example-multiple-tbodies.html

    JS

    $(function() {
    
      $("table").tablesorter({
        theme : 'blue',
        cssInfoBlock : "tablesorter-no-sort",
        widgets: [ 'zebra', 'stickyHeaders' ]
      });
    
    });
    

    HTML

     <tbody class="tablesorter-no-sort">
        <tr><th colspan="4">This row is within the first tbody set as an info block - it is not sorted!</th></tr>
      </tbody>