我正在尝试使用此页面中的表排序器插件。这是一个非常简单的插件,可以在客户端进行排序。
这是我的中继器:
<asp:Repeater ID="RepeaterChangeLog" runat="server" >
<HeaderTemplate>
<table id="ChangeLogTable" class="table tablesorter table-bordered">
<thead>
<tr>
<th>Date de correction</th>
<th>Correcteur</th>
<th>BugID</th>
<th>Catégorie</th>
<th>Module</th>
<th>Description de la correction</th>
<th>Impact</th>
<th>Rapporté par</th>
<th>Demandé par</th>
</tr>
</thead>
</HeaderTemplate>
<ItemTemplate>
<tbody>
<tr>
<td width="125px"> <%# DataBinder.Eval(Container.DataItem, "ChangeLogDate")%></a></td>
<td width="100px"> <%# DataBinder.Eval(Container.DataItem, "FixedBy")%> </td>
<td width="75px"> <%# DataBinder.Eval(Container.DataItem, "BugID")%> </td>
<td width="100px"> <%# DataBinder.Eval(Container.DataItem, "Category")%> </td>
<td width="100px"> <%# DataBinder.Eval(Container.DataItem, "Module")%> <%# DataBinder.Eval(Container.DataItem, "AdditionalModule")%></td>
<td width="300px"> <%# DataBinder.Eval(Container.DataItem, "Description")%> </td>
<td width="300px"> <%# DataBinder.Eval(Container.DataItem, "Impact")%> </td>
<td width="100px"> <%# DataBinder.Eval(Container.DataItem, "ReportedBy")%> </td>
<td width="100px"> <%# DataBinder.Eval(Container.DataItem, "AskedBy")%> </td>
</tr>
</tbody>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
这是我如何称呼表排序器
$(document).ready(function () {
$("#ChangeLogTable").tablesorter();
});
结果很奇怪。我可以看到应用的 CSS,当我单击标题时向上和向下箭头正在更改,但排序本身不起作用。我尝试了在同一页面中找到的一个非常简单的表格,该表格运行良好。我能看到的 2 个之间的唯一区别是,一个是用中继器生成的,另一个只是纯 HTML。在我看来,它应该没有什么区别,因为结果是相同的 html,但也许Microsoft标题中放入一些秘密和隐藏的代码,使插件失败。
我希望有人可以帮助我解决这个问题!谢谢!
我发现了问题,我不敢相信我第一次没有看到它,但是嗯......那天是星期五!
该插件正在使用"新"thead 和 tbody,我不太习惯。当我创建中继器时,我只是将 thead 放在 HeaderTemplate 中,将 tbody 放在 ItemTemplate 中。但我忘记的是,ItemTemplate 在每一行都不断重复,所以我的表有多个正文。这是不行的,插件将无法使用它。换句话说,这是糟糕的HTML。
所以这是好的中继器,将主体放置在正确的位置:
<asp:Repeater ID="RepeaterChangeLog" runat="server" >
<HeaderTemplate>
<table id="ChangeLogTable" class="table tablesorter table-bordered">
<thead>
<tr>
<th>Date de correction</th>
<th>Correcteur</th>
<th>BugID</th>
<th>Catégorie</th>
<th>Module</th>
<th>Description de la correction</th>
<th>Impact</th>
<th>Rapporté par</th>
<th>Demandé par</th>
</tr>
</thead>
<tbody>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td width="125px"> <%# DataBinder.Eval(Container.DataItem, "ChangeLogDate")%></a></td>
<td width="100px"> <%# DataBinder.Eval(Container.DataItem, "FixedBy")%></td>
<td width="75px"><a href="http://adobs.aquadata.com/edit_bug.aspx?id=<%# DataBinder.Eval(Container.DataItem, "BugID")%>"><%# DataBinder.Eval(Container.DataItem, "BugID")%></a></td>
<td width="100px"> <%# DataBinder.Eval(Container.DataItem, "Category")%></td>
<td width="100px"> <%# DataBinder.Eval(Container.DataItem, "Module")%> <%# DataBinder.Eval(Container.DataItem, "AdditionalModule")%></td>
<td width="300px"> <%# DataBinder.Eval(Container.DataItem, "Description")%></td>
<td width="300px"> <%# DataBinder.Eval(Container.DataItem, "Impact")%></td>
<td width="100px"> <%# DataBinder.Eval(Container.DataItem, "ReportedBy")%></td>
<td width="100px"> <%# DataBinder.Eval(Container.DataItem, "AskedBy")%></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</tbody>
</table>
</FooterTemplate>
</asp:Repeater>
我遇到的一个问题是我引用的是中继器 Id,而不是其中表的 Id。