如何在FTL中实现分页(FreeMarker模板)

发布于 2025-02-02 23:54:47 字数 1699 浏览 2 评论 0原文

我想要我的桌子上的分页,就像

prev 1 2 3 4 5 6 Next

数字 1 2 3 ... 将取决于表中的总行就像一张桌子有38行一样,我想一次显示10行。 应显示 1 的前10行,应显示 2 的on Click of of 应显示10行, 3 接下来的10行,onclick 4 剩下的8。

我想要freemarker模板中的代码。 处理?

谁能建议如何

<#assign listOfOrders = EntityQuery.use(delegator).select("orderId").from("OrderItem").queryList()>

<table class="table table-striped" id="myTable">
  <thead class="thead">
    <tr>
      <th scope="col">Order ID</th>
      <th scope="col">No. of Products Associated</th>
    </tr>
  </thead>
  <tbody>      
         <#list listOfOrders as listOrder>
         <tr>
          <td>            
              ${listOfOrders[listOrder?counter - 1].orderId}<br>             
          </td>
           <td>             
               <#assign order =   listOfOrders[listOrder?counter - 1].orderId>
               <#assign count = 0>
               <#list listOfOrders as listOrder>
                  <#if order == listOfOrders[listOrder?counter - 1].orderId>
                    <#assign count = count + 1>
                  </#if>
               </#list>
               <a href="/xerus/control/ListOfProductsFtl?orderId=${listOrder.orderId}" id="view-text"> ${count} </a><br>                 
               <#assign  count = 0>              
          </td>         
        </#list>           
        </tr>       
  </tbody>
</table>

I want pagination for my table which goes like this

prev 1 2 3 4 5 6 next

the numbers 1 2 3 ... will depend on the total rows in a table, like if a table has 38 rows and I want to show 10 rows at a time.
onclick of 1 first 10 rows should be shown, onclick of 2 next 10 rows should be shown, onclick of 3 next 10 rows, onclick of 4 the remaining 8.

I want the code in freemarker template. can anyone suggest how to approach this?see pagination style

my table code is given below.

<#assign listOfOrders = EntityQuery.use(delegator).select("orderId").from("OrderItem").queryList()>

<table class="table table-striped" id="myTable">
  <thead class="thead">
    <tr>
      <th scope="col">Order ID</th>
      <th scope="col">No. of Products Associated</th>
    </tr>
  </thead>
  <tbody>      
         <#list listOfOrders as listOrder>
         <tr>
          <td>            
              ${listOfOrders[listOrder?counter - 1].orderId}<br>             
          </td>
           <td>             
               <#assign order =   listOfOrders[listOrder?counter - 1].orderId>
               <#assign count = 0>
               <#list listOfOrders as listOrder>
                  <#if order == listOfOrders[listOrder?counter - 1].orderId>
                    <#assign count = count + 1>
                  </#if>
               </#list>
               <a href="/xerus/control/ListOfProductsFtl?orderId=${listOrder.orderId}" id="view-text"> ${count} </a><br>                 
               <#assign  count = 0>              
          </td>         
        </#list>           
        </tr>       
  </tbody>
</table>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文