Skip to content

Instantly share code, notes, and snippets.

@a4amaan
Forked from kossoff/test.html.slim
Created February 7, 2020 15:35
Show Gist options
  • Save a4amaan/daddc1a8209f78b01d77188707e041dc to your computer and use it in GitHub Desktop.
Save a4amaan/daddc1a8209f78b01d77188707e041dc 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