Rick Weller
Rick Weller

Reputation: 1258

download file using a button in extjs

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

window.open('export.csv','download')

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?

Upvotes: 2

Views: 5158

Answers (1)

Diodeus - James MacFarlane
Diodeus - James MacFarlane

Reputation: 114347

One method to force a file download is to use a proxy on the server. In general you'd pass the filename to the proxy and it in turn streams out the MIME header and the file.

You can't really do that with EXT though. How you do that will depend on your server-side platform.

See: https://stackoverflow.com/search?q=force+download

Upvotes: 1

Related Questions