【发布时间】:2016-09-16 12:17:32
【问题描述】:
我正在从controller-action 获取值列表以加载到data-table。我检查了值是否已成功从我的控制器操作中获取,但这些值没有加载到data-table .它显示了
没有可用的数据
这是我的控制器。
package com.standout.utilityapplication
import grails.plugin.springsecurity.annotation.Secured
@Secured(['ROLE_ADMIN'])
class ReportController {
AdminService adminService
def report() {
println ("--Inside ReportController");
}
def searchAjax(){
String criteria = params.search_criteria
println ("criteria "+criteria)
if(criteria.equalsIgnoreCase("Employee ID")){
def resultSet = adminService.getReportById(params)
println("----------------+++++ "+resultSet)
[bill_details:resultSet]
}
}
}
这是我的 GSP。
<html>
<head>
<title>Report</title>
<link rel="stylesheet" type="text/css" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"/>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.12/css/dataTables.jqueryui.min.css"/>
<script type="text/javascript" src="//code.jquery.com/jquery-1.12.3.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.12/js/dataTables.jqueryui.min.js"></script>
<script>
function displayTable(){
$(function() {
$('#example').DataTable();
})
document.getElementById('reportSearch').style.display = ''
}
</script>
</head>
<body>
<g:formRemote name="billSearchForm" class="form-horizontal" onComplete="displayTable()" url="[controller: 'Report', action:'searchAjax']">
<div id="reportSearch" style="border-bottom: 1px solid;display:none;padding-right:45px;" class="col-sm-9">
<br/>
<br/>
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Employee Id</th>
<th>Bill Date</th>
<th>Amount</th>
<th>No. of Persons</th>
<th>Bank Submission Date</th>
<th>Bank Submission Status</th>
<th>Bill Date</th>
<th>Reimbursed</th>
<th>Restaurant Name</th>
<th>Team</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Employee Id</th>
<th>Bill Date</th>
<th>Amount</th>
<th>No. of Persons</th>
<th>Bank Submission Date</th>
<th>Bank Submission Status</th>
<th>Bill Date</th>
<th>Reimbursed</th>
<th>Restaurant Name</th>
<th>Team</th>
</tr>
</tfoot>
<tbody>
<g:each in="${bill_details}" var="it">
<tr>
<td>${it.employee_id}</td>
<td>${it.bill_submitted_dt}</td>
<td>${it.amount}</td>
<td>${it.number_of_persons}</td>
<td>${it.presented_bank_dt}</td>
<td>${it.presented_bank_fl}</td>
<td>${it.receipt_dt}</td>
<td>${it.reimbursed}</td>
<td>${it.restaurant_name}</td>
<td>${it.team}</td>
</tr>
</g:each>
</tbody>
</table>
<br/>
<br/>
</div>
</g:formRemote>
</body>
</html>
谁能告诉我该怎么做?
【问题讨论】:
-
所以在控制器中打印时,数据没问题,对吧?如果您只是在 gsp 中将其打印出
${bill_details.size()}会怎样?它显示了什么? -
我认为你的 gsp / jquery 代码有问题。
标签: jquery grails datatables