Skip to content

Instantly share code, notes, and snippets.

@srkama
Forked from elmarcoh/table_init.js
Created August 8, 2014 06:32
Show Gist options
  • Save srkama/9b7d26a1923fd0f4da00 to your computer and use it in GitHub Desktop.
Save srkama/9b7d26a1923fd0f4da00 to your computer and use it in GitHub Desktop.
$('#participantes-table').dataTable({
bProcessing: true,
bServerSIde: true,
sAjaxSource: "/path/to/your/tastypie/api/list/objects/?format=json",
sAjaxDataProp: "objects",
aoColumns: [
// Put the resource name that corresponds to each table column
{'mData': "your"},
{'mData': "columns"},
],
fnServerData: function(source, oaData, callback, settings) {
settings.jqXHR = $.get(
source,
function(data){
// Magic happens here! tastypie provides the data but
// stupid dataTables requires it to have stupid names
data.echo = oaData.echo;
data.iTotalRecords = data.meta.total_count;
data.iTotalisplayRecords = data.meta.limit;
console.debug(data);
console.debug(callback);
callback(data);
},
'json')
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment