2017-01-16 69 views
0
文件按鈕

我們使用的是舊版本的ExtJS的(2.3.0),我遇到一些頭痛與選擇文件按鈕/這裏是我的代碼如何隱藏選擇ExtJS的

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(); 
} 

看樣子2按鈕。我需要影響選擇文件按鈕(正確設置樣式)或至少隱藏瀏覽按鈕。將不勝感激任何意見

+1

這將是很好,如果你分享一些小提琴,讓我們得到實際的UI面前我們。 – Tejas

回答

0

我沒有看到你正在使用自定義'文件',所以它更好地使用它作爲一個自我初始化的項目。

試試這個

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

試試這個..

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} 

檢查this添加下面的類工作提琴。