DataTables在初始化时不发送ajax请求 [英] DataTables do not send ajax request at the initialization
问题描述
如何使用dataTable来实例化表不加载数据(服务器模式),然后在我点击一个按钮时加载数据。如果在初始化时将服务器端设置为true,表将自动发送一个ajax请求,然后渲染数据,这不是我想要的!:(
How to use dataTables to instantiate the table does not load data (server mode),then loading data when i click on a button.If serverSide is set to true at initialization, the table will automatically send an ajax request, then render the data, which is not what I want !:(
推荐答案
看了源代码半天后,我终于首先我需要一个名为firstAjax的自定义参数,并将其设置为false,如下所示:
After looking at the source code for half a day, I finally found a solution. First I needed a custom parameter called firstAjax and set it to false. like this:
$("#example").DataTable({
serverSide: true,
ajax: {
url: 'your url'
},
firstAjax: false
});
然后我更改了
_fnReDraw (settings); //in datatables.js line 4717
到
if (settings.oInit.firstAjax) {
_ fnReDraw (settings);
}
如果压缩的js f ile(datatables.min.js),你应该找到_fnReDraw函数对应的别名。
If the compressed js file(datatables.min.js), you should find _fnReDraw function corresponding alias.
这篇关于DataTables在初始化时不发送ajax请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!