显示数据表中的0条记录中的0条

时间:2014-09-19 19:31:26

标签: java jquery json datatable spring-portlet-mvc

我一直在努力研究数据表很长一段时间,我需要有人帮我实现这个功能。我已经浏览了大部分数据站点,但仍然无法弄明白。

我正在使用spring-portlet MVC。

这是我的脚本。

<script>
        $(document).ready(function() {      

             $('#example').dataTable( {
                    serverSide: true,
                    "bInfo": true,
                    "iDisplayLength":5,
                    "bLengthChange":false,
                    "bFilter": false,
                    "fnRowCallback": function(nRow,aData,iDisplayIndex){

                        $('td:eq(0)', nRow).html('<portlet:renderURL var="serviceSettings"><portlet:param name="action" value="serviceSettings" /><portlet:param name="msisdn" value="'+aData[0]+'"/></portlet:renderURL>'
                       +'<a class="sLinks" href="${serviceSettings}">' +aData[0] + '</a>' );

                        $('td:eq(4)', nRow).html('<portlet:resourceURL var="rechargeHistoryPdf" id="rechargeHistoryPdf"><portlet:param name="msisdn" value="'+aData[0] +'"/></portlet:resourceURL>' + '<a class="has-tooltip" href="#" onclick='+'\'getPdf("${rechargeHistoryPdf}")\''+'  title="View" data-widget="tooltip" data-tip-id="viewTip1" data-tip-position="bottom"><i class="fa fa-search-plus fa-fw"></i>' + '</a>'+
                        '<div id="viewTip1" class="tooltip text-center">View bill for this account</div>' + '<a class="has-tooltip" href="${quickPayUrl}" title="Top Up" data-widget="tooltip" data-tip-id="payTip1" data-tip-position="bottom"><i class="fa fa-credit-card fa-fw"></i>'+ '</a>' + '<div id="payTip1" class="tooltip text-center">Top up for this account</div>' );
                        return nRow;                        
                        },
                    ajax : {
                        url: "${dataTableView}",
                        type: 'POST'
                        }

                    });

                    });


    </script>

我的JSON响应来自类,其代码如下: -

public class DataTablesResponse implements Serializable{
    private static final long serialVersionUID = 1L;

    @JsonProperty(value = "recordsTotal")
    private int totalRecords;
    @JsonProperty(value="recordsDisplay")
    private int displayrecords;
    @JsonProperty(value = "length")
    private int lengthPage;
    @JsonProperty(value="pages")
    private int pages;
    @JsonProperty(value="start")
    private int start;
    @JsonProperty(value="end")
    private int end;
    private String balance;

    public int getTotalRecords() {
        return totalRecords;
    }
    public void setTotalRecords(int totalRecords) {
        this.totalRecords = totalRecords;
    }
    public int getPages() {
        return pages;
    }

    public void setPages(int pages) {
        this.pages = pages;
    }

    public int getStart() {
        return start;
    }

    public void setStart(int start) {
        this.start = start;
    }

    public int getEnd() {
        return end;
    }

    public void setEnd(int end) {
        this.end = end;
    }

    public String getBalance() {
        return balance;
    }

    public int getLengthPage() {
        return lengthPage;
    }
    public void setLengthPage(int lengthPage) {
        this.lengthPage = lengthPage;
    }
    public void setBalance(String balance) {
        this.balance = balance;
    }
    public static long getSerialversionuid() {
        return serialVersionUID;
    }
    public int getDisplayrecords() {
        return displayrecords;
    }

    public void setDisplayrecords(int displayrecords) {
        this.displayrecords = displayrecords;
    }


    @JsonIgnore
    private List<Msisdn> internaldata = new ArrayList<Msisdn>();

    public List<Msisdn> getInternaldata() {
        return internaldata;
    }
    public void setInternaldata(List<Msisdn> data) {
        this.internaldata = data;
    }
    public DataTablesResponse() {
        System.out.println("Inside DataTablsesResponse");
    }

    @JsonProperty(value = "data")
    public List<Object[]> getData() {

        System.out.println("This is the balance amount "+balance);
        List<Object[]> list = new ArrayList<Object[]>();
        for (Msisdn msisdn : internaldata) {
            list.add(new Object[] {msisdn.getMsisdn(),msisdn.getBillingType(),msisdn.getMsisdnStatus(),msisdn.getCurrentBalance(),null});
        }
        //list.add(new Object[] {"total",null,null,balance,null});
        return list;
    }


}

最后一页看起来像this。 JSON响应如下

{"pages":7,"start":0,"end":38,"balance":"1313.015","data":[["98024403","Voice","Active",262.603,null],["98024403","Voice","Active",262.603,null],["98024403","Voice","Active",262.603,null],["98024403","Voice","Active",262.603,null],["98024403","Voice","Active",262.603,null]],"recordsTotal":39,"recordsDisplay":5,"length":5}
杰森通常打开[括号。

为什么我的页面显示0个条目中的0个,以及为什么启动按钮不起作用。

如果您需要更多说明,请将其添加到评论中。

提前致谢。

0 个答案:

没有答案