jquery - how to make first column of data table as hyperlink -
to draw data table used below code
function getdatatable(data1) { var cols = []; var examplerecord = data1[0]; var keys = object.keys(examplerecord); keys.foreach(function(k) { cols.push({ title: k, data: k //optionally type detection here render function }); }); var table = $('#querybuildertable').datatable({ columns: cols }); //add data , draw table.rows.add(data1).draw();}
in first column got caseid want column hyper link user can click on link please in code use json , json key working column name here.
try in following way
$('#querybuildertable').datatable( { "columndefs": [ { "targets": 0, "data": "the_link_defines", "render": function ( data, type, full, meta ) { var returnstring=''; /*here can check condition making link */ if(your condition data obj) returnstring ='<a href="'+data+'"> hyper_link </a>'; else returnstring ='<span>text </span>'; return returnstring ; } } ] } );
and refer following article, article link
Comments
Post a Comment