I need to put a link in a Data Tables cell

I need to put a link in a Data Tables cell

jmflandersjmflanders Posts: 2Questions: 1Answers: 0

I am using Data Tables to display a Sharepoint list. One of the fields in the list is a hyperlink. I need to know how to display the hyperlink in a Data Tables cell.

Answers

  • Muddy WatersMuddy Waters Posts: 19Questions: 6Answers: 0
    $('#table').DataTable({
        order: [[0, 'asc']],
        columns: [
            { title: "id", data: "id",
                render: function(data) {
                    data = '<a href="/page?id=' + data + '">' + data + '</a>';
                    return data;
                }
            },
    
  • jmflandersjmflanders Posts: 2Questions: 1Answers: 0

    I am a newbie with Data Tables. Can you show me the HTML that would go along with the javascript you have provided?

  • Muddy WatersMuddy Waters Posts: 19Questions: 6Answers: 0

    I should have explained my answer assumes ajax returned data with a column of id.

    If your table is static, you should be able to just add a normal 'a' tag to the cell.

    https://datatables.net/examples/data_sources/ajax is an example page

This discussion has been closed.