这是一个奇怪的问题,当我在数据库中有大约500条记录时,“转到页面”标签有时会显示多于应有的页面,有时仅显示4-5页,每页有10条记录。代码:
jquery.jtable.js:
$.extend(true, $.hik.jtable.prototype, {
/************************************************************************
* DEFAULT OPTIONS / EVENTS *
*************************************************************************/
options: {
paging: false,
pageList: 'normal', //possible values: 'minimal', 'normal'
pageSize: 10,
pageSizes: [10, 25, 50, 100, 250, 500],
pageSizeChangeArea: true,
gotoPageArea: 'combobox', //possible values: 'textbox', 'combobox', 'none'
messages: {
pagingInfo: 'Showing {0}-{1} of {2}',
pageSizeChangeLabel: 'Row count',
gotoPageLabel: 'Go to page'
}
},
即使在这里paging
设置为false,我也已将其掩埋在Ajax中。
Ajax代码:
$('#table').jtable({
title: 'ონლაინ სესხების სია',
paging: true,
sorting: false,
defaultSorting: 'loanId ASC',
multiSorting: true,
filteredFields: false,
actions: {
listAction: function (postData, jtParams) {
if (jtParams.jtSorting === undefined) {
jtParams.jtSorting = "";
}
return $.Deferred(function ($dfd) {
if (filteredFields) {
$.ajax({
url: urls.BASE_API + 'user/getOnlineApplicationList?jtStartIndex=' + jtParams.jtStartIndex + '&jtPageSize=' + jtParams.jtPageSize + '&jtSorting='
+ jtParams.jtSorting + '&personalNumber=' + $scope.personalNumber + '&firstname='
+ $scope.firstName + '&lastname=' + $scope.lastName + '&phoneNumber=' + $scope.phoneNumber + '&status=' + $scope.status
+ '&loantype=' + $scope.loantype + '&userId=' + $scope.userId,
type: 'POST',
dataType: 'json',
data: postData,
success: function (data) {
$dfd.resolve(data);
},
error: function () {
$dfd.reject();
}
});
Java代码(仅相关代码)
if (loantype.equalsIgnoreCase("consumer")){
Query query = session.getCurrentSession().createSQLQuery(
"SELECT cl.*, np.*, cpp.*, l.*, br.* " +
"FROM consumer_loan cl " +
"JOIN naturalperson np on cl.customer_id = np.personId " +
"JOIN custpaymentplan cpp on cpp.loanId = cl.loan_id " +
"JOIN loan l on cl.loan_id = l.loanId " +
"JOIN branches br on br.branchId = l.branch_id " + search.toString())
.addEntity("cl", ConsumerLoan.class)
.addEntity("np", NaturalPerson.class)
.addEntity("cpp", CustPaymentPlan.class)
.addEntity("l", Loan.class)
.addEntity("br", Branch.class);
for (String arg : args.keySet()) {
Object val = args.get(arg);
if (val instanceof List<?>) {
query.setParameterList(arg, (List) val);
} else {
query.setParameter(arg, args.get(arg));
}
}
query.setFirstResult(startIndex);
query.setMaxResults(pageSize);
if (query.list().size()>0){
List<Object[]> objList = query.list();
for (Object[] row : objList){
ConsumerLoan cl = (ConsumerLoan) row[0];
NaturalPerson np = (NaturalPerson) row[1];
CustPaymentPlan cpp = (CustPaymentPlan) row[2];
Loan l = (Loan) row[3];
Branch br= (Branch) row[4];
User user = userService.getUser(l.getUserId());
ret.add(new OnlineApplicationListWrapper(l,cpp,np,br,user,cl));
}
查看图片->(在这种情况下,即使您有数百条记录,“转到页面”标签也不显示任何内容)