View Full Version : download a file on button click

16 Apr 2012, 12:38 AM
In a formpanel i have a download button
xtype: 'button',
text: 'Download CSV',
style: 'margin:18px 0 0 10px',
handler: function () {
console.log('download data');


i want to download: export.csv when i click on this button. I tried to do it with

this is working in chrome, ff and ie9. But in ie8 it is not working unless you change a setting in the browser. Is there a better way to download a file using buttons?

16 Apr 2012, 3:47 AM
I typically use an iframe to make a server-side request for a file:

// destroy any existing instance.
try {
catch(e) {
// who you gonna call?

Ext.DomHelper.append(document.body, {
tag: 'iframe',
frameBorder: 0,
width: 0,
height: 0,
css: 'display:none;visibility:hidden;height: 0px;',
src: 'file/download.action?targetFile=someFileIdentifier'