我希望有人可以帮助我...
我对jquery和datatables有点新,但我有以下数据表,当表格使用'mRender'呈现时,我能够在列[1]中创建超链接,如示例所示:
但是我希望超链接的'id'部分来自列[0]的'mData',并在呈现表时显示与列[1]相关联的mData。
这是我的DataTable;
var oTable = $('#allCustomerSummary').dataTable({
//"aaSorting": [[4, "desc"]],
"sAjaxSource": '/GetMyDataLink/CustRel',
"aoColumns": [
{ "mData": "ID" },
{ "mData": "OrganizationName" },
{ "mData": "ContactCount" },
{ "mData": "AccountCount" },
{ "mData": "FacilityCount" },
{ "mData": "HasParentOrg" },
{ "mData": "IsParentOrg" }
],
"aoColumnDefs": [
{ "bvisible": false, "atargets": [0] },
{
"aTargets": [1],
"mData": "ID",
"mRender": function (data, type, full) {
return '<a href="/MySite/CustRel?id=' + data + '">' + data + '</a>';
}
}
],
"sDom":'<p><"pull-left" Cfr>t<"F"i>',
"oLanguage": { "sSearch": "" },
"bScrollInfinite": false,
"iDisplayLength": 15
});
任何帮助都会很高兴得到赞赏:)
答案 0 :(得分:0)
我相信full
函数的mRender
参数是整行的数据,所以请尝试:
"mRender": function (data, type, full) {
return '<a href="/MySite/CustRel?id=' + full[0] + '">' + data + '</a>';
}