Ext JS 3.4:如何在get post后获取表单's请求url

Ext JS 3.4: How to get form's request url after GET post

本文关键字:表单 获取 url 请求 post JS get Ext      更新时间:2023-09-26

我在Ext JS 3.4中有一个表单:

        function exportIE() {
            //var date = new Date();
            //Ext.getCmp('resolvedID').setValue(date);
            // create the window on the first click and reuse on subsequent
            // clicks
            if (!winie) {
                winie = new Ext.Window(
                        {
                            // applyTo:'hello-win',
                            id : 'ie-cl',
                            layout : 'fit',
                            width : 400,
                            height : 100,
                            closeAction : 'hide',
                            plain : true,
                            title : 'Export Individual User Issues to Excel',
                            items : ieform,
                            buttons : [
                                    {
                                        text : 'Submit',
                                        handler : function() {
                                            var url = "$baseUrl/plugins/servlet/timesheet/exportindividualtoexcel?project=$project&month=$month&year=$year&filtered=true";                                               
                                            if(ieform.getForm().isValid()){
                                            winie.hide();
                                            ieform
                                                    .getForm()
                                                    .submit(
                                                            {
                                                                waitMsg : 'Sending...',
                                                                url : url,
                                                                method: 'GET',
                                                                success : function(
                                                                        response,
                                                                        options) {
                                                                    quickcreateform
                                                                            .getForm()
                                                                            .reset();
                                                                    /*Ext.MessageBox
                                                                    .alert(
                                                                            'Success',
                                                                            'Issue resloved');*/
                                                                    //eraseCookie('timeout');
                                                                    //eraseCookie('counter');
                                                                    store.reload();
                                                                    //storechart.loadData();
                                                                    storechart.reload();
                                                                },
                                                                failure : function(
                                                                        response,
                                                                        options) {
                                                                    /*Ext.MessageBox
                                                                            .alert(
                                                                                    'Error',
                                                                                    'Unable to create issue');*/
                                                                    //eraseCookie('timeout');
                                                                    //eraseCookie('counter');
                                                                    quickcreateform
                                                                            .getForm()
                                                                            .reset();
                                                                    store.reload();
                                                                    //storechart.loadData();
                                                                    storechart.reload();
                                                                }
                                                            });
                                                }
                                        }
                                    }, {
                                        text : 'Close',
                                        handler : function() {
                                            ieform.getForm().reset();
                                            //store.reload();
                                            winie.hide();
                                        }
                                    } ]
                        });
            }
            winie.show(this);
        }

所以这个表单是用来下载Apache POI MS Excel文件的,所以我需要把它添加到表单提交成功函数中:

 document.location = request.url;

那么我该怎么做呢?

我需要那个URL也就是Submit GET URL

用于提交表单的URL可从提交中使用的Ext.form.Action获得:

action.getUrl(true)

,其中true参数表示它是一个GET case,因此表单参数需要追加到URL。详细信息请参见源代码。

action对象可作为success函数的第二个参数(如文档所述):

success: function(form, action) {
}

(注意,由于某种原因,您的代码将参数命名为responseoptions)。

因此,您只需从success函数中获取第二个参数并对其调用getUrl(true)

根据上面我做了这个代码,现在它工作了:

var users = Ext.getCmp('select-user-combo').getValue();
document.location = options.getUrl(false)+"&users="+users;