Aug 24, 2022
0
Level 1
How to pass the column id from datatable jquery "data.id" in a laravel route
I was trying to pass the id data from my datatable and send this one to the edit route
$(document).ready(function () {
$('#user-table').DataTable({
processing: true,
serverSide: true,
order: [],
ajax: {
type: "GET",
url: '{{route('config.ajaxindex')}}'
},
columns: [
{ data: 'id' ,
"render": function (data, type, row) {
return '<div class="form-check"> <input class="form-check-input fs-15" type="checkbox" name="checkAll" value="'+row.id+'"> </div>'
}
},
{ data: 'id' },
{ data: 'name' },
{ data: 'email' },
{ data: 'created_at' },
{ data: 'id' ,
"render": function (data, type, row) {
return '<div class="dropdown d-inline-block"><button class="btn btn-soft-secondary btn-sm dropdown" type="button" data-bs-toggle="dropdown" aria-expanded="false"><i class="ri-more-fill align-middle"></i></button><ul class="dropdown-menu dropdown-menu-end">'
// +'<li><a href="" class="dropdown-item" data-bs-toggle="modal" data-bs-target=".bs-example-modal-center"><i class="ri-eye-fill align-bottom me-2 text-muted"></i> Ver</a></li>'
/*Here I try to send the id*/
+'<li><a href="{{route('config.edit',['config' =>" + data.id +" ])}}" class="dropdown-item edit-item-btn"><i class="ri-pencil-fill align-bottom me-2 text-muted"></i> Edit</a></li>'
//+'<li>'+'<a class="dropdown-item remove-item-btn">'+'<i class="ri-delete-bin-fill align-bottom me-2 text-muted"></i> Delete'+'</a>' +'</li>'
+'</ul>'
+'</div>'
}
}
]
});
});
But it is not recognized by the JS the data.id object as you can see in the following pic https://imgur.com/XBGUEU4
Please or to participate in this conversation.