【发布时间】:2020-03-31 17:24:01
【问题描述】:
我正在尝试学习如何将数据从 JSON 数据加载到制表器中。我遇到了错误
tabulator.min.js:3 Data Loading Error - Unable to process data due to invalid data type
Expecting: array
Received: object
我想我需要使用ajaxResponse:function,但不完全确定如何使用。这是我正在使用的 sn-p 代码。
//define data
var data = [ ]
var table = new Tabulator("#tabulator-example", {
height:800,
data:data,
layout:"fitDataStretch",
//ajaxURL:"omdata.json",
// ajaxProgressiveLoad:"scroll",
// paginationSize:20,
placeholder:"No Data Set",
autoResize:true,
ajaxContentType : "application/json; charset=utf-8",
ajaxContentType:"json",
tooltips:true,
addRowPos:"top",
resizableRows:true,
initialSort:[
{column:"feature", dir:"asc"},,
],
columns:[
<REMOVED>
],
});
//trigger AJAX load on "Load Data via AJAX" button click
document.getElementById("ajax-trigger").addEventListener("click", function(){
table.setData("omdata.json");
});
$("#tabulator-controls input[name=feature]").on("keyup", function(){
table.setFilter( "feature", "like", $(this).val())
});
【问题讨论】: