Skip to content

Commit

Permalink
Add download dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
aykutsimseks committed Oct 10, 2018
1 parent 1e65b06 commit ce0df8d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
38 changes: 37 additions & 1 deletion ckanext/datatablesview/public/datatablesview.js
@@ -1,7 +1,43 @@
const run_query = function(params, format) {
console.log(format, params);
}


this.ckan.module('datatables_view', function (jQuery) {
return {
initialize: function() {
jQuery('#dtprv').DataTable({});
const datatable = jQuery('#dtprv').DataTable({});

// Adds download dropdown to buttons menu
datatable.button().add(2, {
text: 'Download',
extend: 'collection',
buttons: [{
text: 'CSV',
action: function (e, dt, button, config) {
const params = datatable.ajax.params();
run_query(params, 'csv');
}
}, {
text: 'TSV',
action: function (e, dt, button, config) {
const params = datatable.ajax.params();
run_query(params, 'tsv');
}
}, {
text: 'JSON',
action: function (e, dt, button, config) {
const params = datatable.ajax.params();
run_query(params, 'json');
}
}, {
text: 'XML',
action: function (e, dt, button, config) {
const params = datatable.ajax.params();
run_query(params, 'xml');
}
}]
});
}
}
});
2 changes: 2 additions & 0 deletions ckanext/datatablesview/public/datatablesview.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -26,7 +26,7 @@
{
"extend": "colvis",
"text": "{{ _('Hide/Unhide Columns') }}"
}{{ ', "copy", "excel", "print"' | safe
}{{ ', "copy", "print"' | safe
if resource_view.get('export_buttons') else ''}}
]'
data-keys='true'>
Expand Down

0 comments on commit ce0df8d

Please sign in to comment.