I've a jQuery datatables plugin which does the following,
<tr>
<th>Id</th>
<th>Datee</th>
<th>Delete</th>
</tr>
$('#data').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "userlist.php",
"aoColumns": [
null,
null,
{
"mDataProp": null,
"sDefaultContent": '<a href="delete.php?action=activate&">DEL</a>'
}
]
} );
So what i'm doing here is that i'm getting data using server side processing and adding an additionalm column with link to delete the record.
Now I want id=<> for that particular record to be added at the end of & in a href as
a href="delete.php?action=activate&id=<<first column value> .
Also i want to convert MySQL date to PHP date for second column.
How can this be done ?
Thanks.
You can do it using getData or using jquery.
Change the following:
To:
then use the following code:
Demo
Using version 1.8.2, I was able to return the html using a function for mDataProp. In your case, it would look like:
Try this: Modify Ricardo's answer as follows:
EDIT: You don't need to have the
id
added to the href attribute of the link when the table is rendered in HTML. The following code will call thedelete.php
script via ajax and will pass the value ofid
to that script.(You will then need to update the displayed datatable as well somehow - there are API functions for this: Delete a row of a datatable).
UPDATE: Another option is to do the following: