Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: Datatables async button eventlisteners

jamie priority asked 2 years 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 2 years 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

  • ForumUser: 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