Javascript Extjs重置文件字段输入

Javascript Extjs重置文件字段输入,javascript,file-upload,extjs,Javascript,File Upload,Extjs,如何在ExtJS中重置文件字段输入?我正在努力: //this - point on Ext.panel.Form var form = this.getForm(); form.reset(); var filefield = this.getForm().getFields().get(0); filefield.reset(); filefield.setValue(''); filefield.value = ''; 但这些方法中没有一种不起作用。谢谢你的帮助 使用下面的代码将

如何在ExtJS中重置文件字段输入?我正在努力:

//this - point on Ext.panel.Form

var form = this.getForm();
form.reset();

var filefield = this.getForm().getFields().get(0);
filefield.reset();

filefield.setValue('');

filefield.value = '';

但这些方法中没有一种不起作用。谢谢你的帮助

使用下面的代码将对您有所帮助

function clearFileUpload(id){
    // get the file upload element
    fileField     = document.getElementById(id);
    // get the file upload parent element
    parentNod     = fileField.parentNode;
    // create new element
    tmpForm        = document.createElement("form");
    parentNod.replaceChild(tmpForm,fileField);
    tmpForm.appendChild(fileField);
    tmpForm.reset();
    parentNod.replaceChild(fileField,tmpForm);
}

以前的帖子,但我也遇到了这个问题,我找到了一个更干净的解决方案

首先,确保filefield设置了allowBlank:true

然后可以调用setRawValue方法,如下所示:

    filefield.setRawValue("");
根据这一回答:

在Ext.ux.form.FileUploadField组件中,在bindListeners函数下的更改事件中添加以下代码

var=this;
setTimeout(函数(){
that.fileInput.dom.value=null;
setValue(that.fileInput.dom.value);
}, 100);      
bindListeners:function(){
此文件名为.fileInput.on({
范围:本,,
mouseenter:function(){
this.button.addClass(['x-btn-over','x-btn-focus'])
},
mouseleave:function(){
this.button.removeClass(['x-btn-over','x-btn-focus','x-btn-click']))
},
mousedown:function(){
this.button.addClass('x-btn-click')
},
mouseup:function(){
this.button.removeClass(['x-btn-over','x-btn-focus','x-btn-click']))
},
更改:函数(){
var v=this.fileInput.dom.value;
这是设定值(v);
this.firevent('fileselected',this,v);
var=这个;
setTimeout(函数(){
that.fileInput.dom.value=null;
setValue(that.fileInput.dom.value);
}, 100);
}
}); 

},
您可能正在寻找的最简单的方法是:

filefield.fileInputEl.dom.value = '';