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
|
null
|
||||||
);
|
);
|
||||||
$button->setButtonIcon('exportlist');
|
$button->setButtonIcon('exportlist');
|
||||||
|
$button->addExtraClass('no-ajax');
|
||||||
return array(
|
return array(
|
||||||
'after' => '<p>' . $button->Field() . '</p>',
|
'after' => '<p>' . $button->Field() . '</p>',
|
||||||
);
|
);
|
||||||
|
@ -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({
|
$('fieldset.ss-gridfield .new-link').entwine({
|
||||||
onclick: function(e) {
|
onclick: function(e) {
|
||||||
this.getGridField().showDetailView($(this).prop('href'));
|
this.getGridField().showDetailView($(this).prop('href'));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user