Accessing data in another column in Datatables

Viewed 11249

I'm using Datatables and I'm trying to access data in another column. It's unclear to me if I should be using columns.data or if I should be taking another approach by using getting the column index instead?

Objective

  • In the second render function, I want the first makeSlug(data) to be referencing the "data": "district" and the second one to remain the same and reference "data": "school"

scripts.js

"columns": [
{ "data": "district",
    "render": function (data, type, row, meta) {
        return '<a href="/schools/' + makeSlug(data) + '">' + data + '</a>';
    }
},
{ "data": "school",
    "render": function (data, type, row, meta) {
        return '<a href="/schools/' + makeSlug(data) + '/' + makeSlug(data) + '">' + data + '</a>';
    }
},
{ "data": "subject"},
{ "data": "rate"},
{ "data": "test_takers"}
],
1 Answers
Related