![](/img/trans.png)
[英]Adding nested data table to a Tabulator cell in a Tabulator table
[英]Load nested data to tabulator table from ajax request
我有一个来自商店的 api。 我用 json 收回请求这样的结构 3 记录在第一级
数据,error_no,味精
在第二级内部数据有
data.items、data.total_pages、data.total_results
内部 data.items(3 级)有我需要加载到制表表的记录。 所以这个嵌套记录我只需要提取和加载项目到表吗? select怎么可能呢?
function loadTableTab(tableData) {
var table = new Tabulator("#table", {
data:tableData, //set initial table data
columns:[
{title:"product_title", field:"product_title"},
{title:"sale_price", field:"sale_price"},
],
});
}
您可以使用ajaxResponse回调以 Tabulator 可以处理的方式格式化数据,它在响应中传递并应返回表数据数组,因此在您的情况下应该是:
function loadTableTab(tableData) {
var table = new Tabulator("#table", {
data:tableData, //set initial table data
ajaxResponse:function(url, params, response){
return response.data.items; // return the array of table items
},
columns:[
{title:"product_title", field:"product_title"},
{title:"sale_price", field:"sale_price"},
],
});
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.