1. #1
    Ext User
    Join Date
    Jan 2008
    Posts
    20
    Vote Rating
    0
    FMIC_DEV is on a distinguished road

      0  

    Post 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.

    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 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.

    the servlet doesn't have a response. it just executes and returns.

    Any ideas here?

  2. #2
    Sencha - Community Support Team hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,962
    Vote Rating
    10
    hendricd will become famous soon enough hendricd will become famous soon enough

      0  

    Default


    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.


  3. #3
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    94
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    Ext will automatically submit to a hidden IFRAME instead of using XMLHttpRequest if you set isUpload: true in your request.

  4. #4
    Sencha - Community Support Team hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,962
    Vote Rating
    10
    hendricd will become famous soon enough hendricd will become famous soon enough

      0  

    Thumbs up


    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.


  5. #5
    Ext User
    Join Date
    Jan 2008
    Posts
    20
    Vote Rating
    0
    FMIC_DEV is on a distinguished road

      0  

    Post 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

Thread Participants: 2