-
29 Jan 2008 7:29 AM #1
export to Excel
export to Excel
Hello All -
I have a servlet that executes the code necessary to export grid data to Excel. However i when i call it with ext.ajax it does't run propertly. when i run it from the browser it runs fine.
here is the code i used to execute the servlet.
the grid renders properly and when i hit the icon to export the data the servlet does in fact run but it doesn't show me the save file dialog box like it does when i run the servlet by itself.Code:var grid1 = new xg.GridPanel({ id:'smGrid', store: statsStore, cm: SDcols, viewConfig: { forceFit:true }, width: 600, height: 300, collapsible: true, animCollapse: false, title: 'Simple Grid from XML Datasource', tbar:[ { icon: '/main/resources/images/excel_x.gif', cls: 'x-btn-icon', tooltip: 'Export to Excel', listeners: { click: {fn: function (){ var url="/main/ExportExcel" Ext.Ajax.request ({ "url": url, "method": "GET", "success": function(response){/* success function. */}, "failure": function(e){/* failure function. show an error message */}, "scope": this }); }}}} ], renderTo: document.body });
the servlet doesn't have a response. it just executes and returns.
Any ideas here?
-
29 Jan 2008 7:33 AM #2
Your best bet is to load your Excel response in a hidden iframe, returning a Content-Disposition header in your response, then the Save dialog should appear.
XMLHttpRequest does nothing with that header tho."be dom-ready..."
Doug Hendricks
Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.
Got Sencha licensing questions? Find out more here.
-
29 Jan 2008 7:36 AM #3Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 40
Ext will automatically submit to a hidden IFRAME instead of using XMLHttpRequest if you set isUpload: true in your request.
-
29 Jan 2008 7:40 AM #4
Nice, Forgot all about that one.
"be dom-ready..."
Doug Hendricks
Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.
Got Sencha licensing questions? Find out more here.
-
29 Jan 2008 8:42 AM #5
Export to Excel
Export to Excel
i created an Iframe on the html page and added isUpload to the request but still no joy.
what do i do on success?
TIA


Reply With Quote

