请求返回结果如下
{
"recordsFiltered": 8,
"data": [{
"userInfo": {
"id": null,
"user_id": null,
"name": "admin",
"name_en": null,
"id_type": null,
"id_num": null,
"birthday": "2017-02-15 19:38:43",
"wechat": null,
"gender": 1,
"origin": null,
"country": null,
"qq": null,
"skype": null,
"head_img_url": null,
"address": null,
"points": null,
"opBy": null,
"opAt": null,
"delFlag": null
},
"user": {
"id": "ceecc59641a34a659caac7f4f85a9dc8",
"loginname": "superadmin",
"password": null,
"salt": null,
"nickname": "超级管理员",
"isOnline": false,
"disabled": false,
"email": "wizzer@qq.com",
"loginAt": null,
"loginIp": null,
"loginCount": null,
"customMenu": null,
"loginTheme": null,
"phone": "18888888888",
"loginSidebar": false,
"loginBoxed": false,
"loginScroll": false,
"loginPjax": false,
"unitid": null,
"unit": null,
"roles": null,
"units": null,
"menus": null,
"firstMenus": null,
"secondMenus": null,
"customMenus": null,
"opBy": null,
"opAt": null,
"delFlag": null
}
}, {
"userInfo": {
"id": null,
"user_id": null,
"name": null,
"name_en": null,
"id_type": null,
"id_num": null,
"birthday": null,
"wechat": null,
"gender": null,
"origin": null,
"country": null,
"qq": null,
"skype": null,
"head_img_url": null,
"address": null,
"points": null,
"opBy": null,
"opAt": null,
"delFlag": null
},
"user": {
"id": "555",
"loginname": "555",
"password": null,
"salt": null,
"nickname": "瓜皮组员",
"isOnline": false,
"disabled": false,
"email": null,
"loginAt": null,
"loginIp": null,
"loginCount": null,
"customMenu": null,
"loginTheme": null,
"phone": null,
"loginSidebar": false,
"loginBoxed": false,
"loginScroll": false,
"loginPjax": false,
"unitid": null,
"unit": null,
"roles": null,
"units": null,
"menus": null,
"firstMenus": null,
"secondMenus": null,
"customMenus": null,
"opBy": null,
"opAt": null,
"delFlag": null
}
}],
"draw": 0,
"recordsTotal": 0
}
datatables需要处理的是一个List<Map<>>每一个map里有一个key为user和一个key为userInfo的键值对
前端生病了,完全不知道怎么设置啊
var datatable;
function initDatatable() {
datatable = $('.datatables-basic').DataTable({
"dom": '<"top">rt<"bottom">lpi<"clear">',
"searching":false,
"pageLength":[10],
"lengthMenu":[5,10,50],
"processing": false,
"serverSide": true,
"select": true,
"ordering": true,
"info":true,
"autoWidth":true,
"language": {
"url": "${base}/assets/plugins/datatables/cn.json"
},
"ajax": {
"url": "${base}/platform/sys/user/dataStudent",
"type": "post",
"data": function (d) {
// d.unitid = $('#unitid').val();
d.loginname = $('#loginname').val();
d.nickname = $('#nickname').val();
}
},
"order": [[1, "desc"]],
"columns": [
{"data": "user.loginname", "bSortable": true},
{"data": "user.nickname", "bSortable": true},
{"data": "user.disabled", "bSortable": true},
{"data": "userInfo.email", "bSortable": true}
],
"columnDefs": [
{
"render": function (data, type, row) {
return '<div class="btn-group ">'+
'<button type="button" class="btn btn-indigo dropdown-toggle btn-ripple" data-toggle="dropdown">'+
' 操 作 <span class="caret"></span>'+
'</button>'+
'<ul class="dropdown-menu" role="menu">'+
'<li><a href="${base}/platform/sys/user/detail/' + row.id + '" data-toggle="modal" data-target="#dialogUserDetail">基本信息</a></li>' +
'<li><a href="${base}/platform/sys/user/menu/' + row.id + '" data-toggle="modal" data-target="#dialogUserRightDetail">查看权限</a></li>' +
'<li class="divider"></li>' +
'<li><a href="${base}/platform/sys/user/edit/' + row.id + '" data-pjax>修改信息</a></li>' +
'<li><a href="javascript:;" onclick="resetPwd(\'' + row.id + '\')">密码重置</a></li>' +
'<li class="divider"></li>' +
'<li><a href="javascript:;" onclick="del(\'' + row.id + '\')">删除</a></li>' +
'<li class="divider"></li>' +
'<li><a href="javascript:;" onclick="enableUser(\'' + row.id + '\')">启用</a></li>' +
'<li><a href="javascript:;" onclick="disableUser(\'' + row.id + '\')">禁用</a></li>' +
'</ul>'+
'</div>';
},
"targets": 4
},
{
"render": function (data, type, row) {
if (!data) {
return '<i id="disable_' + row.id + '" class="fa fa-circle text-green ml5"></i>';
} else {
return '<i id="disable_' + row.id + '" class="fa fa-circle text-red ml5"></i>';
}
},
"targets": 2
}
// {
// "render": function (data, type, row) {
//
// return ' <td><input type="checkbox" class="checkboxes" value=\''+row.id+'\'></td>';
//
// },
// "targets": 0
// }
]
});
datatable.on('click', 'tr', function () {
$(this).toggleClass('selected');
});
$("#searchBtn").on('click', function () {
datatable.ajax.reload();
});
}