Ajax help
Ajax help
Hey guys, Im new to DataTables and Ajax.
Here is a piece of my code:
$(document).ready( function () {
var table = $("#table_id").DataTable({
"ajax": {
"url": "liste/getTable",
"dataSrc":""
},
"columns": [
{"data": "**ID**"},
{"data": "V"},
{"data": "N"},
{"data": "E"},
{"data": "M"},
{"data": "L"},
{"data": "Mail"},
{"defaultContent": '<a onclick="sendMail(**X**);" class="btn btn-primary btn-sm" href="#"><span class="fa fa-envelope"></span></a>'}
]
});
setInterval( function () {
table.ajax.reload();
});
})
Everything is working but how can i put the ID from data: ID into the X in sendMail?
Sry for my bad english, i hope you can help me.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
You would need to use
columns.renderinstead ofcolumns.defaultContent. You would use therowparameter to get theIDfor each row. The columns.render docs have examples that should help.Kevin
I understand that i need to use render. I still dont know how to get the ID. Maybe you could give me a hint
i wrote this:
"rowId": "ID",
table.row( this ).id() did not get the ID though
Thanks alot Kevin!
table.row( this ).id() cant work i guess since i dont click anything... hmm
Hi @Psycho3000 ,
The third argument to
columns.renderis the full data for the row - you can use this to get the value. See example here where the name is being placed into the column with the extension.Cheers,
Colin
Thanks a lot colin!!