[Fixed]-Passing URL Django Pattern in Datatables Column

1đź‘Ť

âś…

Datatables allows you to define a function for the value of “data”. So you can replace {"data" : "Guest Name"} with:

"data": function (row) {
    var $a = $('<a></a>').attr('href', row.guest_name.link).text(row.guest_name.text);
    return $a.prop('outerHTML');
}

This assumes you are replacing the guest_name column with a json object that has a link/text attribute. You could also just pass the link as an escaped javascript string if you know it’s safe wish to keep your datatables/js side simpler.

See more here: https://datatables.net/reference/option/columns.data

👤Chrismit

Leave a comment