简体   繁体   中英

How do I make a column a link in datatables.js?

I am trying to figure out how to make a column a link in dataTables.js. I have it mostly working but can't get the link to appear.

var dataSet = [
 ['PR12345','Test O Rama','5/7/2015','Open'],
 ['PRJ_AR09','Project Name','5/8/2015','New Request'],
 ['PRJ_AR18','Test Project','5/10/2015','New Request'],
 ['PR092134','Test Project 1','5/10/2015','Open'],
 ['PRO012333','Test Project 2','5/10/2015','Open'],
 ['PRO83880','Test Project 3','5/10/2015','Open']
];
$(function() {
    $('#demo').html( '<table cellpadding="0" cellspacing="0" border="0" class="display" id="workQueueTable"></table>' );
    $('#workQueueTable').DataTable({
    "data": dataSet,
    "columns": [
        { "title": "Project ID", "sWidth": "10%", "fnRender": function(data) {
                return "<a href='" + data + "'></a>";
                }  },
        { "title": "Project Name" },
        { "title": "Date Requested", "sWidth": "10%" },
        { "title": "Status", "sWidth": "15%" }
    ]
    });
});

Example Code

Can't seem to get the link to appear?

OK so I found the answer. fnRender has been depreciated so you must use mRender now.

Amazing how everything just works better when you use the correct syntax.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM