2014-08-27 59 views
0

我正在尝试将数据表功能与我的项目集成。我们正在使用Spring portlet MVC。我从服务类获得一个列表。我在JSP中使用的列表是$ {billingOverview.postpaidBillingInfo}。将数据表集成到我的项目中

我在我的代码中包含了以下数据表功能。

<script> 
    $(document).ready(function() { 
     $('#example').dataTable(); 
    }); 
    </script> 

- >示例是表标签中使用的ID。

我的jsp如下:所显示

<%@page import="java.text.SimpleDateFormat, java.util.*"%> 
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%><portlet:defineObjects /> 
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> 
<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%> 
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%> 
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%> 
<script src="${pageContext.request.contextPath}/js/jquery-1.11.1.js" type="text/javascript"></script> 
<script src="${pageContext.request.contextPath}/js/jquery.dataTables.min.js" type="text/javascript"></script> 
<link href="${pageContext.request.contextPath}/css/jquery.dataTables.css" rel="stylesheet" type="text/css" /> 
<%Date d=new Date(); 
SimpleDateFormat sdf=new SimpleDateFormat("dd-MMMM-yyyy"); 
%> 
<script> 
function getPdf(urlLink) { 
    alert("getPdf"); 
$.ajax({ 
    url : urlLink, 
    type : 'GET', 
    dataType : 'text', 
    success : function(data){ 
     alert(data); 
     //window.open(data,"resizeable,scrollbar"); 
    } 
}); 
} 
</script> 
<script> 
     $(document).ready(function() { 
      $('#example').dataTable(); 
     }); 
</script> 


<portlet:resourceURL var="contractLevelBillingPDF" id="contractLevelBillingPDF"> 
       <portlet:param name="contractId" value="${accountOverview.contractId}"/> 
      </portlet:resourceURL> 
<portlet:renderURL var="selectedPostpaidBillingDetails"> 
      <portlet:param name="action" value="getSelectedPostpaidBillingDetails" /> 
</portlet:renderURL> 

<section> 
    <div class="row"> 

     <div class="medium-9 columns content"> 
      <h3 class="title">Billing</h3> 
      <p class="text"><%=sdf.format(d.getTime()) %></p> 
      <hr> 
      <table class="no-margin-top" data-widget="sort-table"> 
       <thead> 
       <tr> 
        <th><div><div class="large dark-purple"><label><spring:message code="label.prevBalance" /></label></div></div></th> 
        <th><div><div class="large pink"><label><spring:message code="label.currentMonth" /></label></div></div></th> 
        <th><div><div class="large light-green"><label><spring:message code="label.totalBalance" /></label> <span class="small"><%=sdf.format(d.getTime()) %></span></div></div></th> 
        <th data-disable-sort=""><div><div class="large grey"><label><spring:message code="label.viewCharges" /></label></div></div></th> 
       </tr> 
       </thead> 
       <tbody> 
       <tr class="no-border"> 
        <td class="text-center large dark-purple">KD ${billingOverview.previousBillAmount}</td> 
        <td class="text-center large pink">KD ${billingOverview.currentBillAmount}</td> 
        <td class="text-center large light-green">KD ${billingOverview.totalBalance}</td> 
        <td class="text-center large"><a href="#" onclick='getPdf("${contractLevelBillingPDF}")' title="View"><i class="fa fa-search-plus fa-fw"></i>View</a></td> 
       </tr> 
       </tbody> 
      </table> 
      <div class="row"> 
       <div class="medium-12 columns text-right"> 
       <portlet:renderURL var="quickPayMethodURL"> 
        <portlet:param name="action" value="quickPay" ></portlet:param> 
        <portlet:param name="contractId" value="${accountOverview.contractId}" ></portlet:param> 
       </portlet:renderURL> 
        <a class="button" href="${quickPayMethodURL}" title="Total Balance">KD ${billingOverview.totalBalance } - PAY NOW</a> 
       </div> 
      </div> 
      <c:if test="${ accountOverview.contractHolder}"> 
      <hr class="dark-purple"> 
      <div class="row"> 
       <div class="large-6 columns"><h3 class="title">Breakdown</h3> </div> 
       <div class="large-6 columns" data-widget="dropdown" data-dropdown-type="select" data-dropdown-search=""> 
        <portlet:renderURL var="selectedPostpaidBillingDetails"> 
         <portlet:param name="action" value="getSelectedPostpaidBillingDetails" /> 
        </portlet:renderURL> 
       <form:form id="selectMsisdnForm" action="${selectedPostpaidBillingDetails}" method="GET" commandName="billingOverview"> 
        <form:select id="selectedMsisdn" path="selectedMsisdn" onchange="this.form.submit()" > 
         <form:option value="All" label="All" /> 
         <form:options items = "${billingOverview.allMsisdnList}" /> 
        </form:select> 
       </form:form> 
       </div> 
      </div> 
      </c:if> 
      <table id="example" data-widget="sort-table" class="display" cellspacing="0" width="100%"> 
       <thead> 
       <tr> 
        <th><div><div><label><spring:message code="label.number" /></div></div></th> 
        <th width="150"><div><div><label><spring:message code="label.type" /></div></div></th> 
        <th><div><div><label><spring:message code="label.status" /></div></div></th> 
        <th width="150"><div><div><label><spring:message code="label.prevBalance" /></div></div></th> 
        <th width="150"><div><div><label><spring:message code="label.currentMonthCharges" /></div></div></th> 
        <th><div><div><label><spring:message code="label.totalAmount" /></div></div></th> 
        <th data-disable-sort=""><div><div><label><spring:message code="label.bill" /></label></div></div></th> 
       </tr> 
       </thead> 
       <c:forEach varStatus = "count" var = "billingOver" items = "${billingOverview.postpaidBillingInfo}"> 
       <tbody> 
       <tr><portlet:renderURL var="serviceSettings"> 
         <portlet:param name="action" value="serviceSettings" /> 
         <portlet:param name="msisdn" value="${billingOver.msisdn}"/> 
        </portlet:renderURL> 
        <td class="text-center"><a href="${serviceSettings}" title="serviceSettings">${billingOver.msisdn}</a></td> 
        <td class="text-center">${billingOver.billingServiceType}</td> 
        <td class="text-center"><i class="fa fa-check fa-fw light-green"></i></td> 
        <td class="text-center">${billingOver.previousBalance}</td> 
        <td class="text-center">${billingOver.currentBalance}</td> 
        <td class="text-center">${billingOver.totalBalance}</td> 
        <td class="text-center"> 
        <portlet:resourceURL var="postpaidNumberBillingPDF" id="postpaidNumberBillingPDF"> 
         <portlet:param name="msisdn" value="${billingOver.msisdn}"/> 
        </portlet:resourceURL> 
         <a class="has-tooltip" href="#" onclick='getPdf("${postpaidNumberBillingPDF}")' title="View" data-widget="tooltip" data-tip-id="viewTip1" data-tip-position="bottom"><i class="fa fa-search-plus fa-fw"></i></a> 
        <portlet:renderURL var="quickPayUrl"> 
         <portlet:param name="action" value="quickPay" /> 
         <portlet:param name="msisdn" value="${billingOver.msisdn}"/> 
        </portlet:renderURL> 
         <!-- <a class="has-tooltip" href="/myzain/corp/quickpay-logged.html" title="View" data-widget="tooltip" data-tip-id="payTip1" data-tip-position="bottom"><i class="fa fa-credit-card fa-fw"></i></a> --> 
         <a class="has-tooltip" href="${quickPayUrl}" title="Pay" data-widget="tooltip" data-tip-id="payTip1" data-tip-position="bottom"><i class="fa fa-credit-card fa-fw"></i></a> 

        </td> 
       </tr> 
       </c:forEach> 
      </table> 

      <div class="row"> 
       <div class="medium-12 columns text-right"> 
        <a class="button" href="/myzain/corp/quickpay-logged.html" title="KD 77.275 DUE - PAY NOW">KD ${billingOverview.totalBalance } - PAY NOW</a> 
       </div> 
      </div> 
     </div> 
    </div> 
</section> 

我的页面是这样的(2份分) 请点击这里看我的jsp。我没有声誉在这里发布。

第一图像链接:https://www.dropbox.com/s/7qw8xcf8ek9vnng/ScreenShot1.png?dl=0 第二图片链接:https://www.dropbox.com/s/dadd009r594nvik/ScreenShot2.png?dl=0

技术问题

在第二图像,它显示在一个时间中的所有记录,而不仅仅是10条记录。它为什么显示所有记录而不仅仅是10条记录。我不知道该怎么做。

为什么它显示一页上的所有记录? WHYYYY?

在此先感谢

回答

0

为什么不呢?您需要参数化数据表以定义您想要对结果进行分页。 有关更多信息,请参见http://legacy.datatables.net/usage/options,尤其是sPaginationType和iDisplayLength参数。

此链接可能会有所帮助:jQuery Datatables pagination setting

+0

当我使用上面的脚本我的其他项目,它只是工作作为罚款。 这个提到的脚本有什么问题。分页默认为true。 – 2014-08-28 05:08:26

+0

你能告诉我如何添加链接到我的领域?我正在实施服务器端分页。 – 2014-09-09 06:35:44

+0

我不明白你的问题。什么链接到什么领域和什么? – 2014-09-09 15:01:40