Getting a hidden column's data in href link
Getting a hidden column's data in href link
mRender
Posts: 151Questions: 26Answers: 13
I have 10 columns, but my first 2 are hidden. In the last column, I have a link that I want to edit the URL for GET variables.
So how would I get the details.php?ID='THE HIDDEN COLUMN INFORMATION"
columns: [
{ data: "name" },
{ data: null, render: function ( data, type, row ) {
// Combine the first and last names into a single table field
return data.address+' '+data.city+' '+data.state+' '+data.zip;
} },
{ data: "tel" },
{ data: "cell" },
{ data: "email" },
{ data: "status" },
{ data: "project_created",
type: "date" },
{
data: null,
className: "center",
defaultContent: '<a href="details.php?='+ data.column[0]'" class="editor_edit">Details</a>'
}
I used to be able to get it like this but I don't know if this works anymore with the updated datatables.
$('td:eq(0)', nRow).html( '<a class="link" href ="details.php?ID='+aData[1]+'">'+aData[1]+'</a>' );
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Update: I found rowCallback and this is what my code looks like now:
It's giving me undefined instead of "DETAILS"
Whelp, never mind. Got it.
My issue was that I was using old code and trying to force it in there. I also had to use data['FIELDNAME'] instead of the hidden index. Thanks for reading :)
I would suggest using
columns.render
. You already are for the first column, so the same basic idea can be applied to the last column.columns.defaultContent
is static only, so that won't help.Allan