<script>
$(document).ready(function() {
//$('#example1').DataTable();
var t = $('#example2').DataTable({
//'bServerSide': true,
"ajax": "${ctx}/XXX/getData",
"columns": [
{ "data": "id"},
{ "data": "dtName" },
{ "data": "cronExpression" },
{ "data": "createTime" },
{ "data": "id"}
],
"columnDefs": [ {
"targets": -1,
"data": "id",
"render": function ( data, type, row, meta ) {
return '<a href="${ctx}/integration/dtInfo?dtId=' + data + '" target="_blank" class="btn btn-xs btn-primary " >查看详情</a>'
+ '<button id="btnChgDIStatus" class="btn btn-xs btn-primary" >' + ('DO' == row.integrationDo ? '停止' : '运行' ) + '</button>';
}
} ],
"bProcessing" : true,
'paging' : true,
'lengthChange': true,
'searching' : true,
'ordering' : true,
'info' : true,
'autoWidth' : true,
"bFilter" : true, //是否启动过滤、搜索功能
"oLanguage": { //国际化配置
"sProcessing" : "正在获取数据,请稍后...",
"sLengthMenu" : "显示 _MENU_ 条",
"sZeroRecords" : "没有您要搜索的内容",
"sInfo" : "从 _START_ 到 _END_ 条记录 总记录数为 _TOTAL_ 条",
"sInfoEmpty" : "记录数为0",
"sInfoFiltered" : "(全部记录数 _MAX_ 条)",
"sInfoPostFix" : "",
"sSearch" : "搜索",
"sUrl" : "",
"oPaginate": {
"sFirst" : "第一页",
"sPrevious" : "上一页",
"sNext" : "下一页",
"sLast" : "最后一页"
}
},
});
t.on( 'draw.dt', function () {
var PageInfo = $('#example2').DataTable().page.info();
t.column(0, { page: 'current' }).nodes().each( function (cell, i) {
cell.innerHTML = i + 1 + PageInfo.start;
} );
} );
t.on('click', 'button#btnChgDIStatus', function () {
var row = t.row($(this).parents('tr'));
var data = row.data();
id = data.id;
$.ajax({
type: "get",
url: '${ctx}/XXX/delRow.do',
data: {
dtId : id,
},
dataType:'json',
cache: false,
success: function(data){
row.remove().draw(false);
//window.location.reload();
}
});
});
})
</script>