Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extjs reset filefield input

How reset filefield input in ExtJS? I am trying:

//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 = '';

But not one of these methods don't work. Thank you for help!

like image 636
vedmed Avatar asked Jun 20 '12 11:06

vedmed


1 Answers

Use below code will help you

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);
}
like image 105
Mayur Avatar answered Oct 04 '22 16:10

Mayur