它确实可以与pagination: "remote"
一起使用,但是**出于某种原因,我们必须在.net中使用自定义ajax函数**而不是ajaxURL
选项。
是功能请求吗?谢谢您的帮助。
以下是以下代码:
<script src="https://cdn.bootcss.com/jquery/1.10.2/jquery.min.js"></script>
<link href="https://unpkg.com/tabulator-tables@4.1.2/dist/css/tabulator.min.css" rel="stylesheet">
<script type="text/javascript" src="https://unpkg.com/tabulator-tables@4.1.2/dist/js/tabulator.min.js"></script>
<script>
function queryRealm(url, config, params) {
return new Promise(function (resolve, reject) {
$.ajax({
url: 'data.php',
success: function(data){
resolve(JSON.parse(data));
},
error: function(error){
reject(error);
}
})
});
}
var table = new Tabulator("#example-table", {
ajaxRequestFunc: queryRealm,
pagination: 'remote',
columns: [{
title: "id",
field: "id",
},
{
title: "Name",
field: "name",
width: 200
}
],
height: "292px",
});
只需将pagination: 'remote',
更改为ajaxProgressiveLoad: "scroll"
然后data.php在下面:
$data = [
["id"=>1, "name"=>"Billy Bob============"],
["id"=>2, "name"=>"Mary May"],
["id"=>3, "name"=>"Christine Lobowski"],
["id"=>4, "name"=>"Brendon Philips"],
["id"=>5, "name"=>"Margret Marmajuke"],
["id"=>6, "name"=>"Christine Lobowski"],
["id"=>7, "name"=>"Brendon Philips"],`enter code here`
["id"=>8, "name"=>"Margret Marmajuke"],
["id"=>9, "name"=>"Margret Marmajuke"],
];
echo(json_encode(["last_page"=>10, "data"=>$data]));
更新了图片 enable ajaxUrl option
答案 0 :(得分:0)
只要您以Tabulator期望的分页格式格式化返回的数据,该方法就应该起作用:
{
"last_page":15, //the total number of available pages (this value must be greater than 0)
"data":[ // an array of row data objects
{"id":1, "name":"bob", "age":"23"} //example row data object
]
}
,您正在正确地将 page 参数传递回服务器。
尽管查看ajaxRequestFunc并没有执行内置ajax系统dosnt已经做的任何事情(尤其是自v4.1以来的改进),所以我不确定为什么首先需要它。
您需要确保 ajaxURL 选项具有一个值,以便调用您的自定义加载程序