【发布时间】:2021-05-04 06:50:34
【问题描述】:
我有下面的数据,我想在 Datatables 的 columns.render 函数中传递两个变量 (id, name)。
我现在只在渲染函数中传递id。
我还想在渲染函数中传递name。
谢谢。
const myData = [
{ id: 2, name: "book" },
{ id: 5, name: "song" },
];
$("#example").DataTable({
data: myData,
columns: [
{
targets: 1,
data: "id",
render: function (data, type, row, meta) {
return (
"<button class='btn btn-default' data_id='" +
data + //id is passed to here
"'>" +
"name" + //the name I want to pass to here.
"</button>"
);
},
},
],
});
【问题讨论】:
标签: javascript jquery datatables