Skip to content

Instantly share code, notes, and snippets.

@cynx
Created August 17, 2015 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cynx/cb9f45f811831a6dceab to your computer and use it in GitHub Desktop.
Save cynx/cb9f45f811831a6dceab to your computer and use it in GitHub Desktop.
index.js of JQUERY DATATABLES 1.10+ & ASP.NET MVC 5 SERVER SIDE INTEGRATION
$(document).ready(function () {
$('#datatab tfoot th').each(function () {
$(this).html('<input type="text" />');
});
var oTable = $('#datatab').DataTable({
"serverSide": true,
"ajax": {
"type": "POST",
"url": '/Home/DataHandler',
"contentType": 'application/json; charset=utf-8',
'data': function (data) { return data = JSON.stringify(data); }
},
"dom": 'frtiS',
"scrollY": 500,
"scrollX": true,
"scrollCollapse": true,
"scroller": {
loadingIndicator: false
},
"processing": true,
"paging": true,
"deferRender": true,
"columns": [
{ "data": "Name" },
{ "data": "City" },
{ "data": "Postal" },
{ "data": "Email" },
{ "data": "Company" },
{ "data": "Account" },
{ "data": "CreditCard" }
],
"order": [0, "asc"]
});
oTable.columns().every(function () {
var that = this;
$('input', this.footer()).on('keyup change', function () {
that
.search(this.value)
.draw();
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment