Hyperlink in td

Hyperlink in td

DrIDrI Posts: 2Questions: 1Answers: 0

Let's dive right in.
I have a function like this. How do I hyperlink specific columns?
Lets say I want to have the TelephoneNumber render like this <a href="tel:0123456789">0123456789</a>
And where 0123456789 is the value of TelephoneNumber.

var table = $('#users').dataTable( {
            "lengthMenu": [ [5,10, 25, 50, -1], [5,10, 25, 50, "All"] ],
            "ajax": "http://domain.com/Users.txt",
            "columns": [
                { "data": "GivenName" },
                { "data": "SurName" },
                { "data": "Department" },
                { "data": "TelephoneNumber" },
                { "data": "EmailAddress" },
                { "data": "Office" },
            ]
         } ).columnFilter();

Thanks.

Answers

  • ignignoktignignokt Posts: 146Questions: 4Answers: 39
    var table = $('#users').dataTable( {
        "lengthMenu": [ [5,10, 25, 50, -1], [5,10, 25, 50, "All"] ],
        "ajax": "http://domain.com/Users.txt",
        "columns": [
        { "data": "GivenName" },
        { "data": "SurName" },
        { "data": "Department" },
        { "data": "TelephoneNumber",
            "fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
                $(nTd).html("<a href='tel:"+oData.TelephoneNumber+"'>"+oData.TelephoneNumber+"</a>");
            }
        },
        { "data": "EmailAddress" },
        { "data": "Office" },
                ]
    }).columnFilter();
    
  • DrIDrI Posts: 2Questions: 1Answers: 0

    Works perfectly, thanks a lot!

This discussion has been closed.