如何排序li元素 [英] how to sort li elements
本文介绍了如何排序li元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下转发器,我想通过项目模板中的li元素对其进行排序..
< asp:Repeater ID =rptSamplerunat =serverClientIDMode =Static
EnableViewState =false>
< HeaderTemplate>
<% - < div class =rt_header1>
< ul>
< li class =flight>航空公司< / li>
< li>离境< / li>
< li class =lft>抵达< / li>
< li class =dur>持续时间< / li>
< li class =lft>票价< / li>
< li class =lft>抵达< / li>
< li class =dur>持续时间< / li>
< li class =lft>票价< / li>
< / ul>
< / div> - %>
< ul id =sort-listclass =asc>
< table id =tblcellpadding =0cellspacing =0border =0class =display>
< thead>
< tr>< td>学生ID< / td>< td> Rollno< / td>< td>学生名< / td>< td> Parentname< / td>
< td> Mobileno< / td>< td>性别< / td>< td>类< / td>< td>部分< / td>< / tr>
< / thead>
< tbody>
< / tbody>
< / table>
< / HeaderTemplate>
< ItemTemplate>
<% - < li runat =server>< / li> - %>
< li class =airline> <%#DataBinder.Eval(Container,DataItem.Stu_ID)%>< / li>
< li class =airline><%#DataBinder.Eval(Container,DataItem.Rollno)%>< / li>
<% - < li>< asp:Label ID =Label4runat =serverText ='<%#Eval(Rollno)%>'Font-Bold =真/>< /锂> - %GT;
< li><%#DataBinder.Eval(Container,DataItem.Studentname)%>< / li>
< li>< asp:Label ID =Label2runat =serverText ='<%#Eval(Parentname)%>'Font-Bold =真/>< /锂>
< li><%#DataBinder.Eval(Container,DataItem.Mobileno)%>< / li>
< li>< asp:Label ID =Label6runat =serverText ='<%#Eval(Gender)%>'Font-Bold =true/> < /锂>
< li>< asp:Label ID =Label7runat =serverText ='<%#Eval(Class)%>'Font-Bold =true/> < /锂>
< li>< asp:Label ID =Label8runat =serverText ='<%#Eval(Section)%>'Font-Bold =true />< /锂>
< / ItemTemplate>
< FooterTemplate>
< / ul>
< / FooterTemplate>
< / asp:Repeater>
解决方案
我不久前遇到过类似的问题,并用JQuery对其进行了排序。看看这个链接
http ://www.designchemical.com/blog/index.php/jquery/sort-items-alphabetically-using-jquery/ [ ^ ]
它应该可以帮助你进行排序
i have the following repeater and i want to sort it by li elements in item template..
<asp:Repeater ID="rptSample" runat="server" ClientIDMode="Static" EnableViewState="false"> <HeaderTemplate> <%--<div class="rt_header1"> <ul> <li class="flight">Airline</li> <li>Departure</li> <li class="lft">Arrival</li> <li class="dur">Duration</li> <li class="lft">Fare</li> <li class="lft">Arrival</li> <li class="dur">Duration</li> <li class="lft">Fare</li> </ul> </div>--%> <ul id="sort-list" class="asc"> <table id="tbl" cellpadding="0" cellspacing="0" border="0" class="display"> <thead> <tr><td>Student ID</td><td>Rollno</td><td>Studentname</td><td>Parentname</td> <td>Mobileno</td><td>Gender</td><td>Class</td><td>Section</td></tr> </thead> <tbody> </tbody> </table> </HeaderTemplate> <ItemTemplate> <%--<li runat="server" ></li>--%> <li class="airline" > <%#DataBinder.Eval(Container, "DataItem.Stu_ID")%></li> <li class="airline"><%#DataBinder.Eval(Container, "DataItem.Rollno")%></li> <%--<li><asp:Label ID="Label4" runat="server" Text='<%#Eval("Rollno") %>' Font-Bold="true"/></li>--%> <li><%#DataBinder.Eval(Container, "DataItem.Studentname")%></li> <li ><asp:Label ID="Label2" runat="server" Text='<%#Eval("Parentname") %>' Font-Bold="true"/></li> <li><%#DataBinder.Eval(Container, "DataItem.Mobileno")%></li> <li><asp:Label ID="Label6" runat="server" Text='<%#Eval("Gender") %>' Font-Bold="true"/></li> <li><asp:Label ID="Label7" runat="server" Text='<%#Eval("Class") %>' Font-Bold="true"/></li> <li><asp:Label ID="Label8" runat="server" Text='<%#Eval("Section") %>' Font-Bold="true"/></li> </ItemTemplate> <FooterTemplate> </ul> </FooterTemplate> </asp:Repeater>
解决方案
I had a similar problem not long ago and sorted it with JQuery. Have a look on this link
http://www.designchemical.com/blog/index.php/jquery/sort-items-alphabetically-using-jquery/[^]
It should help you to do the sorting.
这篇关于如何排序li元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文