i need to pass a record or list of records as a post param to a download action... is that even possible?
Asked
Active
Viewed 77 times
1 Answers
0
A seemingly straight forward question with a complex answer. MDN has written it up better than I could ever do:
https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Forms/Sending_forms_through_JavaScript
For a ExtJS approach you could create a form without rendering it:
var formPanel = Ext.create('Ext.form.Panel', {
url: 'https://www.sencha.com/img/learn/ExtDesignerGettingStarted_html_m4fab468.png',
standardSubmit:true,
baseParams: {
param1: 'textfield',
param2: 123
}
});
formPanel.form.submit();
delete formPanel;
This creates a POST with params like this:
Note that your header will have to respond with specific headers to trigger the download in the browser, see: https://stackoverflow.com/a/3358583/1861459
-
yes i want to use an ExtJS approach but as far as i know an AJAX req cant be used to download a file... I normally use a hidden iframe and pass the params into the query string but in this case it needs to be POST – error123456789 Dec 08 '14 at 15:27
-
Try programmatically creating a Ext form with standardSubmit (unfortunately you have to have a Panel too it seems). Updated the answer with this approach. – pherris Dec 08 '14 at 17:07
-
thanks, just ended up using the hidden form approach. Was hoping there would be something similar for grids but for now this seems to be the best solutions. – error123456789 Dec 08 '14 at 18:28