DataTables

In this example below you will see how to do a DataTables with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by vbmaster, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright vbmaster ©

Technologies

  • HTML
  • JavaScript
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>DataTables</title>
  
  
  <link rel='stylesheet prefetch' href='https://cdn.datatables.net/1.10.13/css/jquery.dataTables.min.css'>
<link rel='stylesheet prefetch' href='https://cdn.datatables.net/buttons/1.2.4/css/buttons.dataTables.min.css'>
<link rel='stylesheet prefetch' href='https://cdn.datatables.net/select/1.2.1/css/select.dataTables.min.css'>
<link rel='stylesheet prefetch' href='https://editor.datatables.net/extensions/Editor/css/editor.dataTables.min.css'>

  
  
</head>

<body>

  <table id="example" class="display" cellspacing="0" width="100%">
	<thead>
		<tr>
			<th>ID</th>
			<th>Rut</th>
			<th>Razón Social</th>
			<th>Giro</th>
			<th>Dirección</th>
			<th>Comuna</th>
			<th>Telefono</th>
		</tr>
	</thead>
	<tfoot>
		<tr>
			<th>ID</th>
			<th>Rut</th>
			<th>Razón Social</th>
			<th>Giro</th>
			<th>Dirección</th>
			<th>Comuna</th>
			<th>Telefono</th>
		</tr>
	</tfoot>
</table>
  <script src='https://code.jquery.com/jquery-1.12.4.js'></script>
<script src='https://cdn.datatables.net/1.10.13/js/jquery.dataTables.min.js'></script>
<script src='https://cdn.datatables.net/buttons/1.2.4/js/dataTables.buttons.min.js'></script>
<script src='https://cdn.datatables.net/select/1.2.1/js/dataTables.select.min.js'></script>
<script src='https://editor.datatables.net/extensions/Editor/js/dataTables.editor.min.js'></script>

  

    <script  src="js/index.js"></script>




</body>

</html>

/*Downloaded from https://www.codeseek.co/vbmaster/datatables-LyPymK */
var editor; // use a global for the submit and return data rendering in the examples

$(document).ready(function() {
	$('#example').DataTable({
		dom: "Bfrtip",
		ajax: "http://138.197.7.205/gt/api/web/empresa",
		columns: [{
			data: "id"
		}, {
			data: "rut"
		}, {
			data: "razon_social"
		}, {
			data: "giro"
		}, {
			data: "direccion"
		}, {
			data: "comuna"
		}, {
			data: "telefono"
		}],
		select: true,
		buttons: [{
			extend: "create",
			editor: editor
		}, {
			extend: "edit",
			editor: editor
		}, {
			extend: "remove",
			editor: editor
		}]
	});
});

Comments