My question is a follow-up to the previous one: How to display a hyperlink in a cell with jQuery DataTables
There is also a Fiddle link provided
I now have the same question, except that my data source is Mysql database table.
In essence, I am now struggling to implement the "rendering of links" while the source "Data" comes from Mysql table (for instance, the values "5555" and "5554" that are linked in the previous example are values in cells in a mysql table).
My understanding (or assumption really) is that the key herein lies within the javascript part previously provided (the "data" source reference as well as the "rendering" part): (the following is simply the "local data sourcing" example provided in the previous answer, this is not the code I use, my code comes second below)
$(document).ready(function (){
var data = [["5555","07/17/2010","RCC Saturday Open","E10","Harris, Fred","1900","Nikolayev, Igor (FM)","2367","1-0"],["5554","07/17/2010","RCC Saturday Open","B01","Nikolayev, Igor (FM)","2367","Motroni, Richard","1728","1-0"]];
var table = $('#example').DataTable({
data: data,
columnDefs: [
{
targets:0,
render: function ( data, type, row, meta ) {
if(type === 'display'){
data = '<a href="basic.php?game=' + encodeURIComponent(data) + '">' + data + '</a>';
}
return data;
}
}
]
});
});
And here is the base-code I am working with currently where I need to incorporate the "data location data" and "rendering" part to get the hyperlinks working:
function fetch_data()
{
var dataTable = $('#user_data').DataTable({
"processing" : true,
"serverSide" : true,
"ajax" : {
url:"fetch.php",
type:"POST"
}
});
My data fetching part is working well via the "fetch.php", but I just don´t know how do I achieve the working links given the data source in my case is external mysql table.
EDIT: Original question resolved. Thank you to @Charlietfl!
EDIT 2: One follow-up question regarding the "GET"-like resemblance of passing variable over the link vs. is the same possible via "POST"? so the links would not become bookmarkable for security purposes?
columnDef's as in static version. The internal rendering works the same regardless of data source