Javascript 对jsp页面上的列进行排序
我想通过单击列对jsp页面中的数据表进行排序。可能使用javascript或JQuery。我只有标题,数据来自数据库Javascript 对jsp页面上的列进行排序,javascript,jquery,jsp,Javascript,Jquery,Jsp,我想通过单击列对jsp页面中的数据表进行排序。可能使用javascript或JQuery。我只有标题,数据来自数据库 <table name="tablesorter" id="tablesorter" class="tablesorter" cellspacing="0" width="720" style="table-layout:fixed;"> <thead> <tr> <th width="90" c
<table name="tablesorter" id="tablesorter" class="tablesorter" cellspacing="0" width="720"
style="table-layout:fixed;">
<thead>
<tr>
<th width="90" class="tableRubrikCell">Anv.namn</th>
<th width="115" class="tableRubrikCell">Namn</th>
<th width="135" class="tableRubrikCell">Roller</th>
<th width="60" class="tableRubrikCell">Ansvarig</th>
<th width="90" class="tableRubrikCell">Skapad datum</th>
<th width="75" class="tableRubrikCell">Giltig tom</th>
<th width="120" class="tableRubrikCell">E-postadress</th>
<th width="40" class="tableRubrikCell">Ta bort</th>
</tr>
</thead>
您可以将插件用于jquery。一般的想法是使用一些初始排序顺序从数据库中获取数据,并在表分类器初始化中设置相同的顺序。
对于表排序器
以json数组的形式获取表行
对要排序的字段上的数组进行排序
遍历json数组并将tr追加到tbody
有关排序,您可以参考此SO链接
数据是通过ajax填充的吗?不是。但我还是成功地把它分类了。