Markcce Eros Markcce Eros - 1 month ago 9
Javascript Question

Javascript dataTable - Adding link to table

I am using javascript dataTable and I'm populating a table by getting the data via an api link this:

jQuery.get(api_url_here", function(dataSet){

jQuery('#myTable').DataTable( {
data: dataSet,
columns: [
{ "data": "id", "title": "theId" },
{ "data": "name", "title": "theName" }


<table id="myTable" class="display"></table>

This all works as required but I need one of the columns to have a link created so that when the user clicks the id it will go to the url assigned with the id...

For example:
<a href="someurl+{id}">theId</a>

How can I do this with dataTable?

"ajax": "./pasien/look/",
aoColumns: [
  { "mData": null }
columnDefs: [{
  "targets": 0,
  "data": null,
  "mRender": function (data, type, row) {
  return '<a href="#">'+ +'</a>';

try this, i use ajax for data in datatables.