我有一个Repeater控件,里面有一些类,但我必须按字母顺序对列表进行排序,包括升序和降序。它不是很完美。请帮我弄清楚问题。我在转发器控件外面使用了两个用于asc和desc的按钮。任何人都可以解决我的问题。
<script type="text/javascript">
$(document).ready(function () {
$('.link-sort-list').click(function (e) {
debugger;
var $sort = this;
var $list = $('.fleftFiveDivs');
var $listLi = $('.box', $list);
//var $listLi = $("input [id*=RepDetails]",$list);
$listLi.sort(function (a, b) {
var keyA = $(a).text();
var keyB = $(b).text();
if ($($sort).hasClass('asc')) {
return (keyA > keyB) ? 1 : 0;
} else {
return (keyA < keyB) ? 1 : 0;
}
});
$.each($listLi, function (index, row) {
$list.append(row);
});
e.preventDefault();
});
});
</script>
<div class="fleftFiveDivs" id="style-4">
<asp:Repeater ID="RepDetails" runat="server">
<ItemTemplate>
<div class="box">
<div class="lblposise">
<img class="group list-group-image" src="../Images/un.png" style="width: 40px; margin-top: -34px;" alt="" />
</div>
<div class="lblposise">
<asp:Label ID="lblvesselname" runat="server" Text='<%#Eval("vesselname") %>' Font-Bold="true" />
</div>
<div class="lblposise">
<asp:Label ID="lblname" runat="server" Text='<%#Eval("name") %>' Font-Bold="true" />
</div>
<div class="lblposise">
<asp:Label ID="lblvesselid" runat="server" Text='<%#Eval("vesselid") %>' Font-Bold="true" />
</div>
<div class="lblposise">
<%-- <asp:Label ID="lblstartdate" runat="server" Text='<%#Eval("SubscriptionActivationDate","{0:dd MMM yyyy}") %>' Font-Bold="true" />--%>
<%# DataBinder.Eval(Container.DataItem, "SubscriptionActivationDate", "{0:dd/MM/yyyy}") %>
</div>
<div class="lblposise">
<%-- <asp:Label ID="lblenddate" runat="server" Text='<%#Eval("TokenSubscriptionDate","{0:dd MMM yyyy}") %>' Font-Bold="true" />--%>
<%# DataBinder.Eval(Container.DataItem, "TokenSubscriptionDate", "{0:dd/MM/yyyy}") %>
</div>
<div class="lblposise">
<asp:Label ID="lblnousers" runat="server" Text='<%#Eval("Users") %>' Font-Bold="true" />
</div>
<div class="lblposise">
75 %
</div>
<div class="lblposise">
75 %
</div>
<div class="lblposise">
Done
</div>
<div class="lblposise">
Done
</div>
<div class="lblposise">
Done
</div>
<div class="lblbtnposi">
<input type="submit" value="View Details" class="btn" />
</div>
</div>
</ItemTemplate>
</asp:Repeater>