Skip to content

Instantly share code, notes, and snippets.

@kossoff
Created September 8, 2016 08:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kossoff/6c9a55c2e7a8aff3df0d756e731e7fb8 to your computer and use it in GitHub Desktop.
Save kossoff/6c9a55c2e7a8aff3df0d756e731e7fb8 to your computer and use it in GitHub Desktop.
Custom parameters for jQuery Datatables with server-side processing
label
input#test-checkbox type="checkbox"
|Test checkbox
table#test-table
javascript:
$(document).ready(function() {
var table = $("#test-table").dataTable( {
"ajaxSource": '#{test_datatable_path}',
"serverSide": true,
"fnServerParams": function (aoData) {
aoData.push({name: "testCheckbox", value: $("#test-checkbox").is(":checked") });
},
"aoColumns": [
{ "sTitle": 'Column 1', "name": 'column1'},
{ "sTitle": 'Column 2', "name": 'column2'},
{ "sTitle": 'Column 3', "name": 'column3', "orderable": false},
],
});
$('#test-checkbox').change( function() { table.fnDraw(); } );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment