mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
BUGFIX Fixed CSV exporting on GridFieldExporter (was calling action via ajax, which doesn't allow HTTP download responses)
This commit is contained in:
parent
dca1b0df1c
commit
dc83ace928
@ -47,6 +47,7 @@ class GridFieldExporter implements GridField_HTMLProvider, GridField_ActionProvi
|
||||
null
|
||||
);
|
||||
$button->setButtonIcon('exportlist');
|
||||
$button->addExtraClass('no-ajax');
|
||||
return array(
|
||||
'after' => '<p>' . $button->Field() . '</p>',
|
||||
);
|
||||
|
@ -6,7 +6,7 @@
|
||||
* @param {successCallback} callback to call after reloading succeeded.
|
||||
*/
|
||||
reload: function(ajaxOpts, successCallback) {
|
||||
var self = this, form = this.closest('form'), data = form.find(':input').serializeArray();
|
||||
var self = this, form = this.closest('form'), data = form.find(':input').serializeArray();
|
||||
if(!ajaxOpts) ajaxOpts = {};
|
||||
if(!ajaxOpts.data) ajaxOpts.data = [];
|
||||
ajaxOpts.data = ajaxOpts.data.concat(data);
|
||||
@ -105,6 +105,28 @@
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Prevents actions from causing an ajax reload of the field.
|
||||
* Useful e.g. for actions which rely on HTTP response headers being interpreted nativel
|
||||
* by the browser, like file download triggers.
|
||||
*/
|
||||
$('.ss-gridfield .action.no-ajax').entwine({
|
||||
onclick: function(e){
|
||||
var self = this, btn = this.closest(':button'), grid = this.getGridField(),
|
||||
form = this.closest('form'), data = form.find(':input').serialize();
|
||||
|
||||
// Add current button
|
||||
data += '&' + encodeURIComponent(btn.attr('name')) + '=' + encodeURIComponent(btn.val());
|
||||
|
||||
// Include any GET parameters from the current URL, as the view state might depend on it.
|
||||
// For example, a list prefiltered through external search criteria might be passed to GridField.
|
||||
if(window.location.search) data = window.location.search.replace(/^\?/, '') + '&' + data;
|
||||
|
||||
window.location.href = $.path.makeUrlAbsolute(grid.data('url') + '?' + data, $('base').attr('href'));
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$('fieldset.ss-gridfield .new-link').entwine({
|
||||
onclick: function(e) {
|
||||
this.getGridField().showDetailView($(this).prop('href'));
|
||||
|
Loading…
x
Reference in New Issue
Block a user