Is possible to add hyper link on datatable columns?

Is possible to add hyper link on datatable columns?

carloawpogicarloawpogi Posts: 2Questions: 2Answers: 0

is it possible to add a hyperlink in datatable columns to redirect to other page?
This is my example

function LoadClassRecordSummary(gradingPeriod) {
$.ajax({
type: "GET",
url: '@Url.Action("GetClassRecordSummary", "ClassRecord")',
data: { gradingPeriodID: gradingPeriod },
success: function (data) {
data = JSON.parse(data)
var cols = [];

                var exampleRecord = data[0];

                var keys = Object.keys(exampleRecord);

                keys.forEach(function (k) {
                    cols.push({
                        title: k,
                        data: k
                    });
                });

                var table = $('#ClassRecordList').DataTable({
                    destroy:true,
                    columns: cols,
                    "responsive": true,
                });
                table.clear();
                table.rows.add(data).draw();
                return table;
            },
            error: function (xhr, status, exception) {
                console.log("Error: " + exception + ", Status: " + status);
            }
        })
    } 

Answers

  • rf1234rf1234 Posts: 2,982Questions: 87Answers: 421

    Here is an example:

    from the table's columns data part:

    {   data: null,
                render: function ( data, type, row ) {
                    return '<a href="http://cookies.insites.com/" </a>';
                }
            },
    
This discussion has been closed.