Topic: Datatables async button eventlisteners

jamie priority asked 1 year ago


In my datatable i get the data from a json api. i want to include an edit button on the table.

how do i add the event listener to the asyncTable const asyncTable = new mdb.Datatable( document.getElementById('datatable'), { columns }, //other bits of code .then((data) => { console.log(data) asyncTable.update({ rows: data.map((posts) => ({ ...posts, postid: posts.id, createddate: posts.createddate, title: posts.title, description: posts.description, publisheddate: posts.publisheddate,
edit: ``<button class="edit-btn btn btn-outline-primary btn-floating btn-sm" data-mdb-id="${posts.id}"><i class="fa fa-marker"></i></button>``, })),


Michał Duszak staff answered 1 year ago


Here is an example on adding buttons to certain rows, and attaching an event listener afterwards: https://mdbootstrap.com/snippets/standard/m-duszak/3703891



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • User: Priority
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: MDB5 3.10.2
  • Device: pc
  • Browser: chrome
  • OS: win11
  • Provided sample code: No
  • Provided link: No