如何在 datatables.js 中创建一个列 link?
How do I make a column a link in datatables.js?
我想知道如何在 dataTables.js 中创建一个列 link。我大部分时间都在使用它,但无法让 link 出现。
var dataSet = [
['PR12345','Test O Rama','5/7/2015','Open'],
['PRJ_AR09','Project Name','5/8/2015','New Request'],
['PRJ_AR18','Test Project','5/10/2015','New Request'],
['PR092134','Test Project 1','5/10/2015','Open'],
['PRO012333','Test Project 2','5/10/2015','Open'],
['PRO83880','Test Project 3','5/10/2015','Open']
];
$(function() {
$('#demo').html( '<table cellpadding="0" cellspacing="0" border="0" class="display" id="workQueueTable"></table>' );
$('#workQueueTable').DataTable({
"data": dataSet,
"columns": [
{ "title": "Project ID", "sWidth": "10%", "fnRender": function(data) {
return "<a href='" + data + "'></a>";
} },
{ "title": "Project Name" },
{ "title": "Date Requested", "sWidth": "10%" },
{ "title": "Status", "sWidth": "15%" }
]
});
});
似乎无法让 link 出现?
好的,所以我找到了答案。 fnRender 已折旧,因此您现在必须使用 mRender。
令人惊讶的是,当您使用正确的语法时,一切都会变得更好。
我想知道如何在 dataTables.js 中创建一个列 link。我大部分时间都在使用它,但无法让 link 出现。
var dataSet = [
['PR12345','Test O Rama','5/7/2015','Open'],
['PRJ_AR09','Project Name','5/8/2015','New Request'],
['PRJ_AR18','Test Project','5/10/2015','New Request'],
['PR092134','Test Project 1','5/10/2015','Open'],
['PRO012333','Test Project 2','5/10/2015','Open'],
['PRO83880','Test Project 3','5/10/2015','Open']
];
$(function() {
$('#demo').html( '<table cellpadding="0" cellspacing="0" border="0" class="display" id="workQueueTable"></table>' );
$('#workQueueTable').DataTable({
"data": dataSet,
"columns": [
{ "title": "Project ID", "sWidth": "10%", "fnRender": function(data) {
return "<a href='" + data + "'></a>";
} },
{ "title": "Project Name" },
{ "title": "Date Requested", "sWidth": "10%" },
{ "title": "Status", "sWidth": "15%" }
]
});
});
似乎无法让 link 出现?
好的,所以我找到了答案。 fnRender 已折旧,因此您现在必须使用 mRender。
令人惊讶的是,当您使用正确的语法时,一切都会变得更好。