【发布时间】:2017-10-22 04:23:18
【问题描述】:
我尝试使用 jQuery 数据表。在我使用引导表之前。 在服务器上,我使用spring boot,spring data with paging。
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>memberId</th>
<th>name</th>
<th>phone1</th>
<th>phone2</th>
<th>email</th>
</tr>
</thead>
</table>
$('#example').DataTable({
"processing": "true",
"serverSide": "true",
"ajax": {
"url": "/rest/members",
"data": function (d) {
return {
search: d.search.value,
page: d.start,
size: d.length
}
},
dataFilter: function (data) {
var json = jQuery.parseJSON(data);
json.recordsTotal = json.totalElements;
json.data = json.content;
return JSON.stringify(json); // return JSON string
}
}
});
使用服务器返回的值,我尝试显示数据。其实什么都没有显示
{
"content":[
{
"memberId":1,
"name":"bob",
"phone1": "450",
"phone2": "1",
"email": "test"
},
{
"memberId":2,
"name":"robert"
"phone1": "2323",
"phone2": "2",
"email": "test"
}
],
"last":true,
"totalElements":27,
"totalPages":1,
"sort":null,
"numberOfElements":27,
"first":true,
"size":100,
"number":0
}
编辑
DataTables 警告:table id=example - 为第 0 行第 0 列请求未知参数“0”。有关此错误的详细信息,请参阅http://datatables.net/tn/4
【问题讨论】:
标签: datatables