var datatable;
function initDatatable() {
datatable = $('.datatable').DataTable({
"dom": '<"toolbar">frtip',
"searching": false,
"processing": false,
"serverSide": true,
"select": true,
"ordering": true,
"language": {
"url": "${base}/assets/plugins/datatables/cn.json"
},
"preDrawCallback": function () {
sublime.showLoadingbar($(".main-content"));
},
"drawCallback": function () {
sublime.closeLoadingbar($(".main-content"));
},
"ajax": {
"url": "${base}/platform/customer/customerstateconfig/data",
"type": "post",
"data": function (d) {
}
},
"order": [[0, "desc"]],
"columns": [
{"data": "serviceId", "bSortable": true}, // 这里的serviceId 在model里,配置的一个
@One(field="serviceId")
private Service_main service_main;
。那么fetchLink 之后,datatable中如何读取service_main中的数据
{"data": "customerStateCode", "bSortable": true},
{"data": "serviceStateCode", "bSortable": true},
{"data": "serviceStateName", "bSortable": true},
],
"columnDefs": [
{
"render": function (data, type, row) {
return '<div class="btn-group"><button type="button" class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown">' +
' <i class="ti-settings"></i> <span class="ti-angle-down"></span></button><ul class="dropdown-menu" role="menu">' +
'<li><a href="${base}/platform/customer/customerstateconfig/edit/' + row.id + '" data-pjax>修改</a></li>' +
'<li><a href="javascript:;" onclick="del(\'' + row.id + '\')">删除</a></li>' +
'</ul></div>';
},
"targets": 4
}
]
});
datatable.on('click', 'tr', function () {
$(this).toggleClass('selected');
});
$("#searchBtn").on('click', function () {
datatable.ajax.reload();
});
}
添加回复
请先登陆