-
6 May 2008 1:48 PM #11
devnull, do you have a form to provide as the form argument? If you don't it will not work. For example if you only have a grid and you need an export button somewhere. If that is the case, add a hidden form element and provide that as the argument. Here's a sample for a formless attachment request:
This is a function I use to get my excel export button. See the part with the form creation and ajax request. If you do have a form in the page, you don't need that part. Just say form: myFormPanel.getForm().el and you're donePHP Code:function getTbExcel() {
if (!Ext.fly('tbExcel')) {
return {
xtype: 'tbbutton',
id: 'tbExcel',
text: 'Excel',
cls: 'x-btn-text-icon',
icon: 'images/icons/excel-s.gif',
handler: function() {
//create dummy form
if (!Ext.fly('frmDummy')) {
var frm = document.createElement('form');
frm.id = 'frmDummy';
frm.name = id;
frm.className = 'x-hidden';
document.body.appendChild(frm);
}
//get attachment
Ext.Ajax.request({
url: 'reports/loadexcel',
form: Ext.fly('frmDummy'),
isUpload: true
});
}
};
} else {
return Ext.getCmp('tbExcel');
}
}
By the way, Animal, how do you feel about this approach for creating/using fields? It's pretty close to the Java getter thing
-
10 Jun 2008 12:44 PM #12
export progress
export progress
Hi,
Off of this, lets say at the time the user clicks the export button I show a progress dialog while the data is being fetched from the server. When the request completes and the file dialog pops up, will Ext.Ajax.request detect the fact the request completed, invoke the callback function, so I can and close the progress dialog?
Thanks,
Fred
-
9 Jul 2008 12:45 AM #13
Hi,
I am also doing something similar, but in my case, I use Java in my server side.
My problem is quite strange, after viewing the grid, and clicking a button to save as a csv file, it goes back to the server, makes a csv file there, then returns to me the url to that file.
Firefox shows the "save file as" dialog but the "Ok" button is disabled. In IE7, nothing happens when I click the button.
I am just doing
var filewin = window.open('$File_path_url');
at my client-side script.
Any ideas what went wrong?
-
16 Aug 2008 11:21 AM #14
Firefox invokes the callback function after the AJAX request, but IE6 doesn't (haven't checked with IE7).
I'm displaying the grid loadMask (GridPanel.loadMask.show()) and when the request completes, I hide it in the callback function.
Firefox invokes the callback function, hides the loadMask and shows the save dialog. IE6 doesn't invoke the callback function and shows the save dialog directly, the loadMask stays on and the callback is never invoked.
Same would apply to your progress dialog. One workaround is not to show any progress dialog, but for long operations, the user might need some feedback.
Can anyone help in resolving this situation for IE ?
-
9 Sep 2008 4:30 AM #15
no "save as" window pops up in IE6
no "save as" window pops up in IE6
hello,
my problem is similar - I have a grid, select some downloads with the checkbox model, click a button and a "save as" window should pop up. works perfect in IE7 and FF but not in IE6. Is there anyone who can help me
I'm using the following scripts and Ext 2.2:
Javascript:
all vars are transported very well to the php script (works in ie7 and ff)Code:/* # there is a grid with the checkboxselection model, from the selected rows I create a # json "array" with the download ids (strParams) - these go to the action handle # which looks for the right files, group and zip them and open a zip save as dialoge */ if (!Ext.fly('frmDummy')) { var frm = document.createElement('form'); frm.id = 'frmDummy'; frm.name = id; frm.className = 'x-hidden'; document.body.appendChild(frm); } Ext.Ajax.request({ url: 'action.php', method : 'POST', form: Ext.fly('frmDummy'), callback: function(o, s, r){ //alert(r.responseText); }, isUpload: true, params: { a: action, documents: strParams } });
PHP:
thanks a lotPHP Code:
// I'm creating an archive here and save it in a temp folder
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header('Content-type: application/zip');
header("Content-Disposition: attachment;filename=" . basename($archive));
//header("Content-Transfer-Encoding: binary ");
readfile($archive);
unlink($archive);
exit;
Ron
-
22 Feb 2009 9:33 AM #16
Hi,
Yes it all works, but with the isUpload method in IE, a security warning appears for the download and if you click yes, the whole page reloads and you are back at the beginning...
Any idea
B
-
15 Jun 2010 11:30 AM #17
Sorry to revive an old thread, but it answered my question "how to save to file" perfectly.
I have tested the solution by keypoint also in IE 6 and it worked, so I'm not sure why it didn't for the others. Perhaps it has to with security settings that are different on my machine? Descheret, Bandorka, did you find out what was causing the issue you were observing?
-
11 Aug 2010 12:10 PM #18
I was looking up something on php.net and found this comment under the header() function. I copied the comment here and made bold text out of the interesting part. And thinking about it does make a lot of sense.

After lots of research and testing, I'd like to share my findings about my problems with Internet Explorer and file downloads.
Take a look at this code, which replicates the normal download of a Javascript:PHP Code:<?php
if(strstr($_SERVER["HTTP_USER_AGENT"],"MSIE")==false) {
header("Content-type: text/javascript");
header("Content-Disposition: inline; filename=\"download.js\"");
header("Content-Length: ".filesize("my-file.js"));
} else {
header("Content-type: application/force-download");
header("Content-Disposition: attachment; filename=\"download.js\"");
header("Content-Length: ".filesize("my-file.js"));
}
header("Expires: Fri, 01 Jan 2010 05:00:00 GMT");
if(strstr($_SERVER["HTTP_USER_AGENT"],"MSIE")==false) {
header("Cache-Control: no-cache");
header("Pragma: no-cache");
}
include("my-file.js");
?>Now let me explain:
I start out by checking for IE, then if not IE, I set Content-type (case-sensitive) to JS and set Content-Disposition (every header is case-sensitive from now on) to inline, because most browsers outside of IE like to display JS inline. (User may change settings). The Content-Length header is required by some browsers to activate download box. Then, if it is IE, the "application/force-download" Content-type is sometimes required to show the download box. Use this if you don't want your PDF to display in the browser (in IE). I use it here to make sure the box opens. Anyway, I set the Content-Disposition to attachment because I already know that the box will appear. Then I have the Content-Length again.
Now, here's my big point. I have the Cache-Control and Pragma headers sent only if not IE. THESE HEADERS WILL PREVENT DOWNLOAD ON IE!!! Only use the Expires header, after all, it will require the file to be downloaded again the next time. This is not a bug! IE stores downloads in the Temporary Internet Files folder until the download is complete. I know this because once I downloaded a huge file to My Documents, but the Download Dialog box put it in the Temp folder and moved it at the end. Just think about it. If IE requires the file to be downloaded to the Temp folder, setting the Cache-Control and Pragma headers will cause an error!
I hope this saves someone some time!
~Cody G.
-
5 Apr 2011 5:46 AM #19
ExtJS 3.3 + Zend Framework + PHPExcel
ExtJS 3.3 + Zend Framework + PHPExcel
Thank you friends, this thread saved hours of headache.
It works for me with ExtJS 3.3 + Zend Framework 1.10 + PHPExcel 1.7.6
For server side code visit PHPExcel forumPHP Code:Ext.Ajax.request({
url: 'myUrl',
form: myWindow.myFormPanel.getForm().el,
params: {myParam: 1},
isUpload: true
});
http://phpexcel.codeplex.com/discussions/250120Last edited by x10; 5 Apr 2011 at 5:47 AM. Reason: added version numbers of Zend and PHPExcel
-
2 Sep 2012 1:35 AM #20
Missing (doc or xls)
Missing (doc or xls)
Hi Guys,
but when I export to word or Excel then downloaded file does not show extension .doc or xls.
Regards
Anurag


Reply With Quote