更新时间:2023-09-20 13:02:22
有一个非常简单实用的基于JQuery的分拣机库,只要您带回所有数据,它就可以很好地对您的表进行排序。看来这是你的情况,因为我看不到基于页面的破坏。
图书馆可以在 http://tablesorter.com 找到[ ^ ]。它需要最少的设置,并将消除服务器往返。
包括javascript库:
There is a very simple and practical JQuery-based sorter library which will sort your table well provided you bring back all the data. It appears this is your case since I see no breaking based upon pages.
The library can be found at http://tablesorter.com[^]. It requires minimum setup and will eliminate the server round-trip.
Include the javascript library:
<script src="/Scripts/jquery.tablesorter.js"></script>
然后初始化分拣机:
Then initialize the sorter:
(document).ready(function(){
(document).ready(function () {
(table)。tablesorter({
headers:{
2:{sorter:false} //我确保用户无法选择
/ /在这里排序第三列。
}
});
});
("table").tablesorter({ headers: { 2: { sorter: false } // I am making sure the user had no option to // sort on the third column here. } }); });
然后将tablesorter类分配给要排序的表,并确保为标题行使用thead元素:
Then assign the tablesorter class to the table you want to sort and make sure you use a thead element for your header row:
<table class="tablesorter">
<thead>
<tr>
<th>Name</th>
<th>Date</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>Joe Schmo</td>
<td>08/26/2015</td>
<td><a href="">Edit</a></td>
</tr>
</tbody>
</table>
这提供了一个非常简单的操作方法,但对于更多细节请转到我在开始时发布的网站链接。希望这会有所帮助,
Juan de Villiers
This provides a very simple how-to, but for more details go to the web site link I posted in the beginning. Hope this helps,
Juan de Villiers