DataTables - columns.render
DataTables Examples
HTML
<link rel="stylesheet" href="//cdn.datatables.net/1.10.0/css/jquery.dataTables.css">
<script src="//cdn.datatables.net/1.10.0/js/jquery.dataTables.js"></script>
<table class="display" id="example">
<thead>
<tr>
<th>Information</th>
<th>Link</th>
</tr>
</thead>
</table>
JavaScript
var responseObj = [
{ "information": "A1", "weblink": "http://www.microsoft.com" },
{ "information": "A2", "weblink": "http://www.yahoo.com" },
{ "information": "A3", "weblink": "http://www.google.com" },
{ "information": "A4", "weblink": "http://www.duckduckgo.com" },
{ "information": "A1", "weblink": "http://www.microsoft.com" },
{ "information": "A2", "weblink": "http://www.yahoo.com" },
{ "information": "A3", "weblink": "http://www.google.com" },
{ "information": "A4", "weblink": "http://www.duckduckgo.com" },
{ "information": "A1", "weblink": "http://www.microsoft.com" },
{ "information": "A2", "weblink": "http://www.yahoo.com" },
{ "information": "A3", "weblink": "http://www.google.com" },
{ "information": "A4", "weblink": "http://www.duckduckgo.com" },
{ "information": "A1", "weblink": "http://www.microsoft.com" },
{ "information": "A2", "weblink": "http://www.yahoo.com" },
{ "information": "A3", "weblink": "http://www.google.com" }
];
$('#example').dataTable({
"data": responseObj,
"bDestroy": true,
"deferRender": true,
"columns": [
{ "data": "information" },
{
"data": "weblink",
"render" : function(data, type, row, meta) {
console.log('render called');
return data;
}
}
]
});