How to add edit button?
How to add edit button?
developer96
Posts: 11Questions: 4Answers: 1
Hi all, I'm trying to add functionality to my datatable like Edit button. I researched the documentation but I'm not able to find the solution. I tried with ** https://datatables.net/extensions/buttons/ ** but can't display the buttons and make it to work. Can someone give me some help or guide how to achieve this? I'm stuck with this for a while so any help will be appreciated.
$(document).ready(function() {
var data;
fetch("http://192.168.2.85:8000/displayPatients/")
.then(response => response.json())
.then(json => data = json)
.then(() => {console.log(data);
let patients = JSON.parse(data.patients_json);
console.log(patients)
$('#datatable').DataTable( {
data: patients,
deferRender: true,
scrollY: false,
scrollX: false,
scrollCollapse: true,
scroller: true,
columns: [
{ data: "fields.coreapi_id" },
{ data: "fields.first_name" },
{ data: "fields.last_name" },
{ data: "fields.email" },
{ data: "fields.date_arrival" },
{ data: "fields.date_departure" },
],
} )
})
} );
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
There is no mention of buttons in your code.
The documentation is quite clear and includes everything you need. Why can't you follow it?
I deleted this part of code because I'm confused if this is the right way, but this is the whole code I tried, I got no error in DevTools, could you please take a look?
Are you including the Buttons js extension file?
No, I forgot about this, but now it works with button 'copy', I just need to find the dom of 'edit' button. Thank you for your help)))