Get started with datatables.net-editor-bs5 CDN
SEE LICENSE IN License.md licensed
Datatables.net-editor-bs5: library for Bootstrap 5 data table editing with Datatables.
Tags:- DataTables
- Editor
- Bootstrap
Stable version
Copied!
How to start using datatables.net-editor-bs5 CDN
<!DOCTYPE html>
<html>
<head>
<title>Get started with datatables.net-editor-bs5 CDN - cdnhub.io</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.11.5/css/dataTables.bootstrap5.min.css">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.6/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.min.js"></script>
<script src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/editor/2.2.0/js/dataTables.editor.min.js"></script>
<script src="https://cdn.datatables.net/editor/2.2.0/js/editor.bootstrap5.min.js"></script>
</head>
<body>
<div class="container mt-5">
<table id="example" class="table table-bordered table-striped">
<thead>
<tr>
<th>Name</th>
<th>Age</th>
<th>City</th>
<th>Actions</th>
</tr>
</thead>
</table>
</div>
<script>
$(document).ready(function() {
$('#example').DataTable({
language: {
url: '//cdn.datatables.net/plug-ins/1.11.5/i18n/English.json'
},
dom: 'Bfrtip',
buttons: [
'create', 'edit', 'remove'
],
ajax: {
url: '/api/data',
type: 'GET'
},
columns: [
{ data: 'name' },
{ data: 'age' },
{ data: 'city' },
{
data: null,
orderable: false,
searchable: false,
render: function(data, type, row) {
return '<button class="btn btn-primary btn-sm edit-btn" data-id="' + row.id + '">Edit</button>';
}
}
],
order: [[0, 'asc']],
paging: false,
info: false
});
$('#example').on('click', '.edit-btn', function() {
var id = $(this).data('id');
new $.fn.dataTable.Editor({
table: '#example',
language: {
url: '//cdn.datatables.net/plug-ins/1.11.5/i18n/English.json'
},
ajax: {
url: '/api/data/' + id,
method: 'GET'
},
fields: [
{ label: 'Name', name: 'name' },
{ label: 'Age', name: 'age' },
{ label: 'City', name: 'city' }
],
instance: true
}).edit(this);
});
});
</script>
</body>
</html>
Copied!
Copied!
Copied!
Copied!