如何在 jquery 数据表中显示 'processing'?
how can I display 'processing' inside jquery datatable?
我正在使用 jquery datatables(angular datatables) 进行服务器端处理,消息 'processing' 在table。我可以通过 sDOM (lfrtip) 更改位置,但是是否可以将其放入数据中table(将 p 放入 t)?
是的...有几种方法可以做到这一点。我喜欢用 "loading gif"。所以,你的 HTML 看起来像这样:
<table id="main_index">
<img id="loading_gif" src="images/ajax-loader.gif"> <!--this is your loading image or div-->
</table>
然后您希望在 table 加载后隐藏此 .gif。您为此使用 datatables 回调函数。例如:
$("#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 的区域内,请使用此结构:
<table id="main_index">
<div id="table_processing">Whatever text you want</div>
</table>
然后您可以使用我的原始答案中的代码隐藏它,以便在 table 加载时隐藏它 div。
processing
选项需要设置为true
和
在 sDom
选项中需要字母 r
。
var options = {
"sDom": 'prtp',
"processing": true,
"serverSide": true,
"ajax": "/path/to/my/ajax.php"
}
var oTable = $('.datatables').dataTable(options);
我正在使用 jquery datatables(angular datatables) 进行服务器端处理,消息 'processing' 在table。我可以通过 sDOM (lfrtip) 更改位置,但是是否可以将其放入数据中table(将 p 放入 t)?
是的...有几种方法可以做到这一点。我喜欢用 "loading gif"。所以,你的 HTML 看起来像这样:
<table id="main_index">
<img id="loading_gif" src="images/ajax-loader.gif"> <!--this is your loading image or div-->
</table>
然后您希望在 table 加载后隐藏此 .gif。您为此使用 datatables 回调函数。例如:
$("#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 的区域内,请使用此结构:
<table id="main_index">
<div id="table_processing">Whatever text you want</div>
</table>
然后您可以使用我的原始答案中的代码隐藏它,以便在 table 加载时隐藏它 div。
processing
选项需要设置为true 和在
sDom
选项中需要字母r
。var options = { "sDom": 'prtp', "processing": true, "serverSide": true, "ajax": "/path/to/my/ajax.php" } var oTable = $('.datatables').dataTable(options);