我正在使用带有服务器端处理的 jquery 数据表(角度数据表),消息“处理”在表格上方。我可以通过 sDOM (lfrtip) 更改位置,但是是否可以在数据表中进行更改(将 p 放入 t 中)?
问问题
919 次
2 回答
2
是的...有几种方法可以做到这一点。我喜欢使用“加载 gif”。因此,您的 HTML 如下所示:
<table id="main_index">
<img id="loading_gif" src="images/ajax-loader.gif"> <!--this is your loading image or div-->
</table>
然后,您希望在表格加载后隐藏此 .gif。您为此使用数据表回调函数。例如:
$("#main_compare").DataTable({
//all of your other datatables configuration followed by a comma then...
"drawCallback": function(settings, json) {
$('#loading_gif').hide(); //hides the loading image once table is loaded
//do anything else you want to have happen only once the table is loaded
}
})
编辑
根据您的评论,我认为这就是您要寻找的。
如果您希望在加载时在表格区域内显示消息,请使用以下结构:
<table id="main_index">
<div id="table_processing">Whatever text you want</div>
</table>
然后,您可以使用我的原始答案中的代码隐藏它,以在表格加载时隐藏此 div。
于 2016-02-23T15:44:10.690 回答
0
- 该
processing
选项需要设置为 true 和 在
sDom
选项中需要这封信r
。var options = { "sDom": 'prtp', "processing": true, "serverSide": true, "ajax": "/path/to/my/ajax.php" } var oTable = $('.datatables').dataTable(options);
于 2017-12-14T11:17:44.543 回答