我正在尝试使用制表器加载动态数据,我可以使用以下代码生成表和数据:
$("#example-table").tabulator({
layout:"fitColumns",
columns:[ //Define Table Columns
{title:"Name", field:"name", width:150},
{title:"Age", field:"age", align:"left", formatter:"progress"},
{title:"Favourite Color", field:"col"},
{title:"Date Of Birth", field:"dob", sorter:"date", align:"center"},
],
});
var tabledata = [
{id:1, name:"Oli Bob", age:"12", col:"red", dob:""},
{id:2, name:"Mary May", age:"1", col:"blue", dob:"14/05/1982"},
{id:3, name:"Christine Lobowski", age:"42", col:"green", dob:"22/05/1982"},
{id:4, name:"Brendon Philips", age:"125", col:"orange", dob:"01/08/1980"},
{id:5, name:"Margret Marmajuke", age:"16", col:"yellow", dob:"31/01/1999"},
];
// $("#example-table").tabulator("setData", []);
$("#example-table").tabulator("setData", tabledata);
但是,当我尝试重新加载相同的数据 onclick 函数时,我收到错误:
Options Error - Tabulator does not allow options to be set after initialization unless there is a function defined for that purpose
所以我的问题是如何清空表的数据并重新加载新数据或相同数据