Appending Data to link
Appending Data to link
Mylo_92
Posts: 1Questions: 1Answers: 0
Good Day,
I have the following initialization method written within a Laravel Based Application:
<script>
$(function() {
$('#users-table').DataTable({
bprocessing: true,
serverSide: true,
ajax: '{!! route('datatables.data') !!}',
columns: [
{ data: 'id', name: 'id' },
{ data: 'sponsor_name', name: 'sponsor_name' },
{ data: 'sponsor_contact_name', name: 'sponsor_contact_name' },
{ data: 'sponsor_contact_number', name: 'sponsor_contact_number' },
{ data: 'sponsor_fax', name: 'sponsor_fax' },
{ data: 'sponsor_address', name: 'sponsor_address' },
{ data: 'sponsor_email', name: 'sponsor_email' }
],
aoColumnDefs: [
{
"aTargets": [7],
"mData": 'id',
"mRender": function (data, type, full) {
return '<a href="{{route('user-edit', ' + full[0] ')}}"><button><i class="fa fa-pencil"></i></button></a>';
}
}
]
});
});
</script>
To be concise, I would just like to know how to access and append, the id retrieved from my table, to the link or data assigned to the mRender variable
Thank you in advance.
Kind Regards
This discussion has been closed.
Answers
full.id
should do it. You are using objects (based on the fact that you have specifiedcolumns.data
) so accessing an array (full[0]
) isn't going to work.full
is just the original data source object for the row.Allan