如何放置一个条件来判断如果数据不为空,则会出现"找不到"按钮,否则将隐藏.假设客户端收到来自API的AJAX响应.
success: function(response){
var result;
if (response.data != null){
result = "dataNotNull";
} else {
result = "dataNull";
}
loadFunc(result);
}
function loadFunc(result){
$('#myTable').DataTable({
buttons: [
{
text: 'Missmatch',
titleAttr: 'Download in Excel',
action: function ( e, dt, node, config ) {
func_expMissMatch();
}
},
{
text: 'Not Found',
titleAttr: 'Download in Excel',
action: function ( e, dt, node, config ) {
func_expNotFound();
}
}
]
});
}