0

我是在动态内容的jsp页面中做这种排序技术的新手。我的应用程序与 struts2+jsp+hibenate 集成。我在jsp中使用以下代码。

报告.jsp

          <table class="report_view_table" id="results">
    <thead>
        <tr> <th width="35" scope="col" abbr="no">No
            </td>
            <th width="50" scope="col" abbr="status">Date
            </td>
            <th width="80" scope="col" abbr="option">productName
            </td> 
        </tr>
    </thead>
    <tbody>
  <s:if test="resultList.size() > 0">
  <s:if test="productName.size() > 0">
  <s:iterator status="rowNo" value="resultList">
      <s:set name="Result_product" value="%{productId}" />
  <tr> <td><span class="check"><s:property value="%{#rowNo.count}" /></span></td>
       <td><span class="check"><s:property value="%{proDate}" /></span></td>
       <td><span class="check"><s:iterator value="productName"> 
           <s:set name="product"value="%{productId}" /> 
           <s:if test="%{#product== #Result_product}">
        <s:property value="%{productionName}" /> </s:if></s:iterator>
       </span></td>
   </tr>
   </s:iterator>
   </s:if>
   </s:if>
   <s:else>No report is available
   </s:else>
    <s:else>No report is available
   </s:else>
       </tbody>
   </table>

在这里,我想按列标题对表格进行排序。如何对表格的这个动态内容进行排序。任何人都请帮我做这个功能。提前谢谢

4

1 回答 1

0

客户端排序使用jquery dataTable

对于使用 jquery 数据表,将表的 id 指定到 jquery 数据表。例如 results 是你的表的 id

为 jquery 和 jquery 数据表添加 javascript 文件

$(document).ready(function(){
    $('#results').dataTable();
});

服务器端排序:使用 Arrays.sort() 通过接口 Comparable 参考http://docs.oracle.com/javase/tutorial/collections/interfaces/order.html对服务器端的结果列表进行排序

于 2012-06-28T07:10:59.620 回答