gpt4 book ai didi

jquery - grails应用程序的jquery数据表中未填充值

转载 作者:行者123 更新时间:2023-12-02 14:49:38 25 4
gpt4 key购买 nike

我正在从controller-action中获取值列表以加载到data-table中。我检查了是否已从 Controller 操作中成功获取了值,但未将值加载到data-table中。

No data available



这是我的 Controller 。

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>


谁能告诉我该怎么办?

最佳答案

请尝试使用以下代码段。
html-table文件中的gsp内容
您可以根据需要将其他自定义内容添加到表中。

              <table id="userDataTable" class="table table-bordered table-striped tableWidth dataTable">
<thead>
<tr>
<th>Branch Name</th>
<th>User Name</th>
<th>First Name</th>
<th>Last Name</th>
<th>Contact Number</th>
</tr>
</thead>
</table>

用于 加载/合并jquery中的数据的 data-table内容
var userDetailsDataTable = "";

userDetailsDataTableReload : function(){

userDetailsDataTable = $('#userDataTable').DataTable();
userDetailsDataTable.destroy();

userDetailsDataTable = $('#userDataTable').DataTable({
"ajax": '../restaurantManagement/fetchUserDetails'
});

}

从这里开始,我们调用 Controller 操作 fetchUserDetails controller-action内容
    Map userDetailsMap      =   [:]

List userDetailsList = userManagementService.fetchAllUsersByRestaurantId(restaurantId)

userDetailsMap << [data : userDetailsList]

render userDetailsMap as JSON

让我知道是否有问题。

关于jquery - grails应用程序的jquery数据表中未填充值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39531332/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com