How to Add Button on Each Row in Datatable

How do I add button on each row in datatable?

Basically your code is okay, thats the right way to do this. Anyhow, there are some misunderstandings:

  1. fetchUserData.cfm does not contain key/value pairs. So it doesn't make sense to address keys in mData. Just use mData[index]

  2. dataTables expects some more info from your serverside. At least you should tell datatables how many items in total are on your serverside and how many are filtered.
    I just hardcoded this info to your data. You should get the right values from counts in your server sided script.

    "aaData": [
  3. If you have the column names already set in the html part, you don't need to add sTitle.

  4. The mRender Function takes three parameters:

    • data = The data for this cell, as defined in mData
    • type = The datatype (can be ignored mostly)
    • full = The full data array for this row.

So your mRender function should look like this:

  "mRender": function(data, type, full) {
return '<a class="btn btn-info btn-sm" href=#/' + full[0] + '>' + 'Edit' + '</a>';

Find a working Plunker here

DataTable add a button to each row

You need a database to persist the state of button. Check below link for server-side processing:

How to add buttons in each row of data table?

you might be able to use the scoped slot in the component try this:

<template v-slot:cell(actions)="data">
<button @click="myAction">Click</button>

how to add edit/delete buttons in each row of datatable

well for update and delete button , you need an ID, i assumed the id on database will named as id

 $(document).ready(function() {
"bProcessing": true,
"sAjaxSource": "fetchdata.php",
"aoColumns": [
{ mData: 'title' } ,
{ mData: 'name' },
{ mData: 'year_name' },
mData: '',
render: (data,type,row) => {
return `<a href='link_to_edit/${}'>update</a>`;

reference this

Datatable get button on each row

You can use the node function .node() function to get the element of the selected row. Then you can wrap it in jQuery to perform jQuery actions on it like this:

    $('#apply-all').on('click', function (e) {
var table = $('.mydatatable').DataTable();
table.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
var data =; // able to fetch the data.
var row = this.node();
var rowJqueryObject = $(row);
$(row).find('button'); //will return all buttons in that row
} );

Adding button to each row of a datatable with event in angular 2

You can do it using defaultContent key in columns object of datatable. First you need to create a <th> for showing the button column. I have created a stackblitz for achieving this. Please read the comments i have added in that stackblitz carefully before implementing it in your logic. I have added three buttons in it which show the data of current row. See: Buttons In Datatable

Is there a way to add button on each row in datatable? [react js]

in my project I use for this purpose something like this:

let buttonDetails = "<a href='" + urlDetails + "' title='" + titleDetails +"' class='dtDetails' data-target='#remoteModal1' data-toggle='modal' data-backdrop='static'><span class='glyphicon glyphicon-search'></span></a>";

let buttonEdit = "<a href='"+urlEdit+"' title='"+titleEdit+"' class='dtEdit' data-target='#remoteModal' data-toggle='modal' data-backdrop='static'><span class='glyphicon glyphicon-pencil'></span></a>";

let buttonDelete = "<a href='" + urlDelete + "' title='" + titleDelete +"' class='dtDelete' data-target='#remoteModal1' data-toggle='modal' data-backdrop='static'><span class='glyphicon glyphicon-remove'></span></a>";


"columnDefs": [
"targets": [2],
"width": miCustomWidth,
"className": "center",
"data": function (d) {
return buttonDetails.replace("ID_X", d.rowIdField) + " " + buttonEdit.replace("ID_X", d.rowIdField) + " " + buttonDelete.replace("ID_X", d.rowIdField);

Vue - how can i add a button to each row in a Vuetify datatable?

You can add a new column, set value to action for example, and add a slot in the table as follows:

new Vue({
vuetify: new Vuetify(),
data() {
return {
search: '',
headers: [
{ text: 'Asset', value: 'symbol' },
{ text: 'Amount', value: 'amount' },
{ text: 'Send', value: 'action' }
balances: [
{ symbol: "$", amount: 100 },
{ symbol: "$", amount: 200 },
methods: {
sendRequest(rowData) {
<script src=""></script>
<script src=""></script><link href=",300,400,500,700,900" rel="stylesheet">
<link href="" rel="stylesheet">
<link href="" rel="stylesheet">

<v-app id="app">
<template v-slot:item.action="{ item }">
<v-btn @click="sendRequest(item)">

Related Topics

Leave a reply