Table Sorter to sort when i have more rows in thead

时光毁灭记忆、已成空白 提交于 2019-12-13 03:22:46

问题


I have a table with more than 2 rows in and i wnt to perform sorting only on 2nd row elements, how can this be achieved using table sorter?Please help me out.


回答1:


I have a similar situation, but I only use the first row for tablesorter. The second row is used for selection filters, so I always want it to stay at row 2. Putting both rows in but making the second row cells instead of <th> cells does the trick.

<table id="table" class="tablesorter">
   <thead>
      <tr>
         <th title="Click to sort by ID ">ID</th>
         <th title="Click to sort by Name ">Name</th>
         <th title="Click to sort by Description ">Description</th>
      </tr>
      <tr>
         <td><input type="text" name="org_id"/></td>
         <td><input type="text" name="name"/></td>
         <td><input type="text" name="business_desc"/></td>
      </tr>
   </thead>
   <tbody>
      <tr>
         <td>Org 1</td>
         <td>Org Name</td>
         <td>Org Desc</td>
      </tr>
   </tbody>
</table>



回答2:


BY default it will take your last .

for changing it to first you can use. var table = $('#stu_view_example1 ').DataTable({ orderCellsTop: true or "bSortCellsTop": true });



来源:https://stackoverflow.com/questions/1502014/table-sorter-to-sort-when-i-have-more-rows-in-thead

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!