DataTables columnDefs.targets

DataTables columnDefs.targets

HTML

<link rel="stylesheet" href="https://nightly.datatables.net/css/jquery.dataTables.min.css">
<script src="https://nightly.datatables.net/js/jquery.dataTables.min.js"></script>
<table id="example" class="display" cellspacing="0" width="100%">
    <thead>
        <tr>
            <th>First name</th>
            <th>Last name</th>
            <th>Position</th>
            <th>Office</th>
            <th>Start date</th>
            <th>Salary</th>
            <th>sdfdf</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Tiger</td>
            <td>Nixon</td>
            <td>Software Engineer</td>
            <td>Edinburgh</td>
            <td>2011/07/25</td>
            <td>$170,750</td>
            <td></td>
        </tr>
    </tbody>
</table>

JavaScript

var table = $('#example').DataTable( {
    columns: [
        { data: 'first_name' },
        { data: 'last_name' },
        { data: 'position' },
        { data: 'office' },
        { data: 'salary' },
        { data: 'start_date' },
    ],
    columnDefs: [ {
        targets: 0,
        className: 'testing',
        defaultContent: '<button >ยกเลิก</button>'
    }],
} );