【问题标题】:HTML Table Sorting in jQuery [closed]jQuery中的HTML表格排序[关闭]
【发布时间】:2013-06-16 01:43:40
【问题描述】:

我有一个简单的 HTML 表格,我需要在 jQuery 的每一列上添加排序和分组。

<table cellspacing='0'>
<thead>
    <tr>
        <th>Task Details</th>
        <th>Progress</th>
        <th>Vital Task</th>
    </tr>
</thead>
<tbody>
    <tr>
        <td>Create pretty table design</td>
        <td>100%</td>
        <td>Yes</td>
    </tr>

</tbody>

【问题讨论】:

  • 太棒了。我有时也需要东西。但是您尝试过什么?
  • 你想说什么?

标签: jquery html-table


【解决方案1】:

有各种插件可以使用 jQuery 执行此操作。最广为人知的是 jQuery tablesorter:

http://tablesorter.com/docs/

这里有很多这样的插件,选择你最喜欢的一个:

http://www.tripwiremagazine.com/2013/06/jquery-filter-sort-plugins.html

【讨论】:

  • 谁能给我这个的代码,没有插件。
  • 检查这里:stackoverflow.com/questions/3160277/jquery-table-sort - 但是,它对我不起作用 - 表格不可排序。为什么不想使用插件?
  • 我想在我自己的插件中使用 int..
  • 检查这些插件的代码并将其调整为您自己的。或者,您可以简单地在您的插件中要求它需要另一个插件才能工作(例如 jQuery UI 需要 jQuery)
【解决方案2】:

您可以为此使用tablesorter。使用起来非常简单。

$(document).ready(function() { 
   $("#myTable").tablesorter();  // <-- 'myTable' is the id of your table    
}); 

Here你可以查看一个工作演示

【讨论】:

    【解决方案3】:

    我建议使用datatables,你可以这样使用:

    $(document).ready(function(){
        $('#example').dataTable();
    });
    

    【讨论】:

      【解决方案4】:

      不要重新发明轮子。使用jquery tablesorter插件。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-07-03
        • 2016-02-03
        • 1970-01-01
        • 2011-03-10
        • 1970-01-01
        • 2012-07-13
        • 2014-03-18
        相关资源
        最近更新 更多