Last active
December 4, 2017 13:09
-
-
Save oniram88/10730767 to your computer and use it in GitHub Desktop.
File Download
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ext.define( 'DownloadFile', { | |
requires:['Ext.form.Panel'], | |
downloadFile:function ( config ) { | |
config = config || {}; | |
var url = config.url, | |
method = config.method || 'POST',// Either GET or POST. Default is POST. | |
params = config.params || {}; | |
// Create form panel. It contains a basic form that we need for the file download. | |
var form = Ext.create( 'Ext.form.Panel', { | |
standardSubmit:true, | |
url:url, | |
method:method | |
} ); | |
// Call the submit to begin the file download. | |
form.submit( { | |
target:'_blank', // Avoids leaving the page. | |
params:params | |
} ); | |
// Clean-up the form after 100 milliseconds. | |
// Once the submit is called, the browser does not care anymore with the form object. | |
Ext.defer( function () { | |
form.close(); | |
}, 100 ); | |
} | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tu use this:
include in your class with mixin:
and then in your class you can use: