Javascript 如何在extJs中隐藏“选择文件”按钮

Javascript 如何在extJs中隐藏“选择文件”按钮,javascript,extjs,extjs2,Javascript,Extjs,Extjs2,我们使用的是旧版本的extJS(2.3.0)。我对“选择文件”按钮感到有些头疼/这是我的代码 var uploadBtn = new Ext.Panel({ tbar : [ {text: 'Upload CSV file', id: 'upload-btnn', handler: uploadHandler} // tbbutton is the default xtype if not specified ] }); var fileField = new

我们使用的是旧版本的extJS(2.3.0)。我对“选择文件”按钮感到有些头疼/这是我的代码

var uploadBtn = new Ext.Panel({
    tbar : [
        {text: 'Upload CSV file', id: 'upload-btnn', handler: uploadHandler} // tbbutton is the default xtype if not specified
    ]
});


var fileField = new Ext.ux.form.FileUploadField({
     fieldLabel: 'File name',
     id: 'form-file',
     emptyText: 'Select a Document',
     name: 'file', 
     hideButton: true                      
     //buttonText: 'Оберіть файл'       
});

var fileUploader = new Ext.FormPanel({
   id:'upload-form',
   fileUpload: true,
   header: false,
   hidden: true,
   labelWidth: 75,
   frame:true,
   bodyStyle:'padding:5px 5px 0',
   autoWidth: true,
   //defaultType: 'textfield',
   items: [          
      fileField
   ],
   buttons: [{
      text:'upload',
      handler: submitIt
   },{
      text: 'cancel',
      handler: function(){
         fileUploader.getForm().reset();
         fileUploader.hide();
         //$('upload-btnn').show();
         //uploadBtn.show();
      }
   }],
   border:false,
   scope: this
});



function submitIt(){
   fileUploader.getForm().isValid();
   fileUploader.getForm().submit({
      url: 'links_generation/file_upload',        
      clientValidation: false,
      waitMsg: 'Uploading your Document...',
      success: function(fp, o){
         //msg('Success', 'Processed file "'+o.result.file+'" on the server');

         fileUploader.getForm().reset();             
         //fileUploadWin.hide();
      },
      failure: function(a,b) {            
         fileUploader.getForm().reset();
         //fileUploadWin.hide();
      }
   });
}   

function uploadHandler(){
    this.hide();      
    fileUploader.show();
}

它显示为两个按钮。我需要影响“选择文件”按钮(以正确设置其样式)或至少隐藏“浏览”按钮。如果您有任何建议,我将不胜感激。

我看不出您正在使用自定义的“文件字段”,因此最好将其用作自初始化项

试试这个

items: [
     {          
      xtype:'filefield', //change the xtype as per doc
      fieldLabel: 'File name',
      id: 'form-file',
      emptyText: 'Select a Document',
      name: 'file', 
      hideButton: true  
     }
   ]
试试这个

 items: [{
    xtype: 'filefield',
    name: 'photo',
    fieldLabel: 'Upload a file',
    emptyText: 'Click here to browse files...',
    labelWidth: 100,
    msgTarget: 'side',
    allowBlank: false,
    anchor: '100%',
    buttonText: '',
    buttonConfig: {
      cls: 'browseBtnCls'
    }
  }]
并在css中添加以下类

.browseBtnCls {padding: 0px !important;background-color: transparent !important; border-color: transparent; width: 0px}

检查工作提琴。

如果你能分享一些提琴,这样我们就能看到真实的用户界面,那就太好了。