Skip to content

Instantly share code, notes, and snippets.

@michalg-
Last active August 29, 2015 14:17
Show Gist options
  • Save michalg-/959cfecd6c5d350c9009 to your computer and use it in GitHub Desktop.
Save michalg-/959cfecd6c5d350c9009 to your computer and use it in GitHub Desktop.
$(document).on "page:change page:load", ->
$table = $('#dt_basic')
#setting defaults
$.extend $.fn.dataTable.defaults,
processing: true
serverSide: true
type: "POST"
"sServerMethod": "POST"
pagingType: 'full_numbers'
ajax: $table.attr('data-source')
#turning off sorting
oTableSettings = {}
oTableSettings.aoColumns = []
$('thead th', $table).each ->
obj = $(this)
obj_d = obj.data('datatable')
if obj_d and obj_d.bSortable != undefined
oTableSettings.aoColumns.push 'bSortable': obj_d.bSortable
else
oTableSettings.aoColumns.push null
#fire up datatable
$table.dataTable
stateSave: true
sDom: "<'dt-toolbar'<'col-xs-12 col-sm-6'f><'col-sm-6 col-xs-12 hidden-xs'l>r>" + "t" + "<'dt-toolbar-footer'<'col-sm-6 col-xs-12 hidden-xs'i><'col-xs-12 col-sm-6'p>>"
"aoColumns": oTableSettings.aoColumns
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment