How to add tag html in Ajax sourced data

How to add tag html in Ajax sourced data

jaenajajaenaja Posts: 2Questions: 1Answers: 0
edited July 2017 in Free community support

I need to add tag html in td all colunm it working but column insert tag a not working
$(document).ready(function() {
$('#example').DataTable( {
"ajax": "api/all",
"columns": [
{ "data": "du_id" },
{ "data": "site_id" },
{ "data": "status" },
{ "data": "submission_end_time" },
{ "data": "region" },
** { "data": '<a href="'+"id"+'">Action</a>' }**
]
} );
} );

This question has an accepted answers - jump to answer

Answers

  • bindridbindrid Posts: 730Questions: 0Answers: 119
    Answer ✓

    You want to use the rendering feature

            $(document).ready(function() {
                $('#example').DataTable( {
                    "ajax": "api/all",
                    "columns": [
                    { "data": "du_id" },
                    { "data": "site_id" },
                    { "data": "status" },
                    { "data": "submission_end_time" },
                    { "data": "region" },
                    { "data": "id", render: function (dataField) { return '<a href="' + dataField + '">Action</a>'; } }
                    ]
                } );
            } );
    
  • jaenajajaenaja Posts: 2Questions: 1Answers: 0

    it working thankyou very much

This discussion has been closed.