Skip to content

Instantly share code, notes, and snippets.

@zopyx
Created May 2, 2017 08:32
Show Gist options
  • Save zopyx/c82fdf7312a9d803f46eae9c6ec4ccc8 to your computer and use it in GitHub Desktop.
Save zopyx/c82fdf7312a9d803f46eae9c6ec4ccc8 to your computer and use it in GitHub Desktop.
<script type="text/javascript">
$(document).ready( function () {
try {
order = DT_ORDER_BY;
} catch(e) {
order = [0, "asc"];
}
var editor = new $.fn.dataTable.Editor( {
ajax: '/api/staff',
table: '#listing',
fields: [
{ label: 'First name', name: 'first_name' },
{ label: 'Last name', name: 'last_name' },
]
} );
var table = $('#listing').DataTable({
columnDefs: [ {
targets: 'no-sort',
orderable: false,
} ],
pageLength: 50,
autoWidth: false,
initComplete: function(settings, json) {
$('#listing').show();
},
order: order,
aLengthMenu: [25, 50, 100, 250, 500, 750, 1000, 2000, 3000],
dom: 'Bfrtip',
select: true,
/*
columns: [
{ data: 'first_name' },
{ data: 'last_name' },
],
buttons: [
{ extend: 'create', editor: editor },
{ extend: 'edit', editor: editor },
{ extend: 'remove', editor: editor }
],
*/
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment