制表符 - 渐进 Ajax 加载
Tabulator - Progressive Ajax Loading
制表符:4.9 - Google Chrome
我似乎无法让 ajaxProgressiveLoad
按预期运行。 (构造函数如下所示)。
php 文件查询 SQL 数据库和当前 returns 107,000
记录,并被 return 编辑为 json
:
echo(json_encode(["last_page"=>1, "data"=>$data]));
(附带问题参考 last_page - 在处理大型数据集时如何确定?)
SQL 查询本身需要大约 1.5 秒才能 return 数据,但制表符似乎在等待所有数据,然后在 20 秒后显示所有记录。
20:26:29.586 Callback: ajaxRequesting
20:26:51.059 Callback: ajaxResponse
此数据集预计会增长,用户最好立即或至少在几秒钟后看到一些数据。我在构造函数或 php 文件中遗漏了什么吗?
提前感谢您提供的任何指导
克里斯
var table = new Tabulator("#tabulator-table", {
index:"Counter",
//initialSort:[{column:'Date', dir:'desc'}],
height:(window.innerHeight - 100),
layout:"fitDataStretch",
tooltips:true,
tooltipsHeader:true,
placeholder:"Please wait - retrieving data....",
ajaxURL:"tabulatorSELECT_vMPS_Extract.php",
ajaxParams:{CDSDealerCodes:strCDSDealerCodes},
ajaxProgressiveLoad:"load",
//ajaxProgressiveLoadDelay:200, //wait 200 milliseconds between each request
ajaxRequesting:function(url, params){
//url - the URL of the request
//params - the parameters passed with the request
console.log("Callback: ajaxRequesting");
},
ajaxResponse:function(url, params, response){
//url - the URL of the request
//params - the parameters passed with the request
//response - the JSON object returned in the body of the response.
console.log("Callback: ajaxResponse");
return response; //return the response data to tabulator
},
headerFilterPlaceholder:"...",
columns:[
{title:'Date', field:'Date', headerFilter:'input', sorter:'datetime', bottomCalc:'count'},
{title:'Amount', field:'Amount', headerFilter:'input', hozAlign:'right', formatter:"money", bottomCalc:"sum", bottomCalcParams:{formatter:"money"}, bottomCalcFormatter:"money"},
{title:'Currency', field:'Currency', headerFilter:'input'},
{title:'Programme', field:'Programme', headerFilter:'input'}
]
});
渐进式 ajax 加载的要点是您 DONT 一次性发送所有数据,这正是你在那里做什么,这就是为什么它 运行 慢。
您应该一次将数据分页成 20 行的块(行数由您决定)
Tabulator 将在需要显示时逐页请求数据,它会告诉您 return 随请求一起发送的 page
参数中的哪个块。
return编辑数据中的last_page
属性应该是可用行总数除以页面大小(四舍五入)
制表符:4.9 - Google Chrome
我似乎无法让 ajaxProgressiveLoad
按预期运行。 (构造函数如下所示)。
php 文件查询 SQL 数据库和当前 returns 107,000
记录,并被 return 编辑为 json
:
echo(json_encode(["last_page"=>1, "data"=>$data]));
(附带问题参考 last_page - 在处理大型数据集时如何确定?)
SQL 查询本身需要大约 1.5 秒才能 return 数据,但制表符似乎在等待所有数据,然后在 20 秒后显示所有记录。
20:26:29.586 Callback: ajaxRequesting
20:26:51.059 Callback: ajaxResponse
此数据集预计会增长,用户最好立即或至少在几秒钟后看到一些数据。我在构造函数或 php 文件中遗漏了什么吗?
提前感谢您提供的任何指导 克里斯
var table = new Tabulator("#tabulator-table", {
index:"Counter",
//initialSort:[{column:'Date', dir:'desc'}],
height:(window.innerHeight - 100),
layout:"fitDataStretch",
tooltips:true,
tooltipsHeader:true,
placeholder:"Please wait - retrieving data....",
ajaxURL:"tabulatorSELECT_vMPS_Extract.php",
ajaxParams:{CDSDealerCodes:strCDSDealerCodes},
ajaxProgressiveLoad:"load",
//ajaxProgressiveLoadDelay:200, //wait 200 milliseconds between each request
ajaxRequesting:function(url, params){
//url - the URL of the request
//params - the parameters passed with the request
console.log("Callback: ajaxRequesting");
},
ajaxResponse:function(url, params, response){
//url - the URL of the request
//params - the parameters passed with the request
//response - the JSON object returned in the body of the response.
console.log("Callback: ajaxResponse");
return response; //return the response data to tabulator
},
headerFilterPlaceholder:"...",
columns:[
{title:'Date', field:'Date', headerFilter:'input', sorter:'datetime', bottomCalc:'count'},
{title:'Amount', field:'Amount', headerFilter:'input', hozAlign:'right', formatter:"money", bottomCalc:"sum", bottomCalcParams:{formatter:"money"}, bottomCalcFormatter:"money"},
{title:'Currency', field:'Currency', headerFilter:'input'},
{title:'Programme', field:'Programme', headerFilter:'input'}
]
});
渐进式 ajax 加载的要点是您 DONT 一次性发送所有数据,这正是你在那里做什么,这就是为什么它 运行 慢。
您应该一次将数据分页成 20 行的块(行数由您决定)
Tabulator 将在需要显示时逐页请求数据,它会告诉您 return 随请求一起发送的 page
参数中的哪个块。
return编辑数据中的last_page
属性应该是可用行总数除以页面大小(四舍五入)