ExtJS Implementing the Download function

Source: Internet
Author: User

Tangled for a long time, finally realized the ExtJS download function, in fact, the principle of downloading is very simple, is to give the interface a button, let the button trigger the background action, the address back to the foreground. The specific implementation is as follows.

//extjs Code, page

var btn_out_user = new Ext.button ({ text: ' Export Excel ', Iconcls: ' Icon-del ', Handler: function() {  Ext.MSG.Show({ title:' Confirm export ', msg: ' Are you sure you exported the data? ', Buttons: Ext.MSG.YESNO, width: -, fn: function(btn){    if(btn==' yes '){              Ext.MessageBox.wait(' exporting data, please wait ... ', ' Tips ');                Ext.Ajax.Request({ URL: ' Outshopinfoaction.action ', Success: function(resp,Ops){        varobj= Ext.Decode(resp.ResponseText); window.Parent.Document. Location=obj.Path;//Assign a value to the address        Ext.MessageBox.UpdateProgress(1); //Set progress bar              Ext.MessageBox.Hide();  //Close progress bar Ds_user.Load({params : {Start: 0,Limit: -}});       }, Failure: function() {        Ext.MessageBox.UpdateProgress(1);                Ext.MessageBox.Hide();          Ext.MSG.Show({ title: ' ERROR hints ', msg: ' An error occurred while deleting! ', width: $, Buttons: Ext.MSG.OK, icon: Ext.MSG.ERROR        });      }     });    }      }, icon: Ext.MessageBox.QUESTION  });  } });

The background calling program is as follows:

public voidout ()throws Exception {String = ".. /upload/test.xls "; this. GetResponse (). getwriter (). Write ("{' Path ': '"+outpath+"'}");  }

Here the request is to use JSON data passing, in the daemon, pass a parameter path, its value is: String Outpath = ". /upload/test.xls ". The foreground is responsible for receiving this parameter, and the value of this parameter is obtained by the parameter name.

var=Ext. Decode (resp. ResponseText ); window . Parent . Document . = obj. Path ;

Through the above method, you can give the foreground push value in the background.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.