问题描述
有一个很艰难的时间搞清楚了这一点。我需要在一个ExtJS应用程序在.csv文件提交表格,然后下载数据。问题是,一路上ExtJS的有我提交表单以isUpload我张贴正在发送为mulitpart /表单数据,我不能使用它们,或分析它们的参数。我有相同的输入字段名的多个值。
字段:一个
现场:乙
现场:C
当我提出我的网格,他们去了像上面的多个实例。当我提出isUpload他们去接管的形式:
字段:A,B,C
我的程序读取场为A,B,C,而不是三个独立的领域的实例!
下面是我的code。有趣的是,当我检查萤火虫的PARAMS标签看起来是正确的,但在开机自检选项卡,然后在同一个值。
我刚刚添加的URL参数的尝试和假吧!
Ext.Ajax.request({
网址:/cgi-bin/cgijson007.pgm'+'? +参数,
形式:myForm的,
params:一个参数,
standardSubmit:真正的,
isUpload:真
});
isUpload:真的只是定义了要上载与字段的文件,所以多部分是正确的。要下载我推荐你使用一个隐藏帧。对于使用一个命名空间中定义的帮手。
helper.util.HiddenForm =功能(URL,域){
如果(!Ext.isArray(场))
返回;
变种体= Ext.getBody(),
帧= body.createChild({
标签:IFRAME,
CLS:X-隐藏,
编号:'hiddenform-IFRAME',
名称:IFRAME
}),
表= body.createChild({
标签:'形式',
CLS:X-隐藏,
编号:'hiddenform形式,
动作:URL,
目标:IFRAME
});
Ext.each(字段,函数(EL,I){
如果(!Ext.isArray(EL))
返回false;
form.createChild({
标签:输入,
类型:文本,
CLS:X-隐藏,
ID:hiddenform-'+ EL [0]
名称:EL [0]
值:EL [1]
});
});
form.dom.submit();
返回框架;
}
//使用它像
helper.util.HiddenForm(我的/ realtive /路径,[字段名,fieldValue方法]);
如果通过下载服务器答案保存窗口将弹出。
Having a really hard time figuring this out. I need to submit a form in an ExtJS application and then download the data in a .CSV file. The problem is, the way ExtJS has me submitting the form with "isUpload" the parameters I'm POSTing are being sent as "mulitpart/form-data" and I can't consume them or parse them. I have multiple values of the same input field name.
field: A
field: B
field: C
When I submit for my grids they go over as multiple instances like above. As soon as I introduce "isUpload" to the form they go overs as:
field: A,B,C
My program reads field as "A,B,C" and not three separate instances of field!
Here's my code. Interesting that when I examine in Firebug the Params tab looks correct, but the POST tab has then all in one value.
I just recently added the parameters to the url to try and fake it out!
Ext.Ajax.request({
url : '/cgi-bin/cgijson007.pgm' + '?' + parameters,
form : myForm,
params : parameters,
standardSubmit : true,
isUpload : true
});
isUpload: true only defines that you want to upload a file along with fields, so multipart is correct. To download I recommend you to use a hidden frame. For that use a helper defined within a Namespace.
helper.util.HiddenForm = function(url,fields){
if (!Ext.isArray(fields))
return;
var body = Ext.getBody(),
frame = body.createChild({
tag:'iframe',
cls:'x-hidden',
id:'hiddenform-iframe',
name:'iframe'
}),
form = body.createChild({
tag:'form',
cls:'x-hidden',
id:'hiddenform-form',
action: url,
target:'iframe'
});
Ext.each(fields, function(el,i){
if (!Ext.isArray(el))
return false;
form.createChild({
tag:'input',
type:'text',
cls:'x-hidden',
id: 'hiddenform-' + el[0],
name: el[0],
value: el[1]
});
});
form.dom.submit();
return frame;
}
// Use it like
helper.util.HiddenForm('my/realtive/path', [["fieldname","fieldValue"]]);
If the server answer with a download the save window will popup.
这篇关于ExtJS的提交表单下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!