I have several columns defined using datatables. I assign "mData" which I manipulate mRender to display. However, I would like to display two data variables in one column in order to create a link, something like this:
{"mData": "foo",
"mData2": "bar",
"mRender": function(data, data2){
return '<a href="/data/' + data + '">bar</a>'; //
}
}
Is there a way to do this?
The mRender
function is passed the data for the whole row. So, you can access any property you want:
{
mData: "bar",
mRender: function(data, type, val) {
switch (type) {
case 'display':
return '<a href="/data/' + data.foo + '">' + data.bar + '</a>';
break;
// optionally, add case statements for 'sort', 'filter', and 'type'
default:
return data.bar;
break;
}
}
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments