qq_33873617 2016-02-03 07:47 采纳率: 50%
浏览 2036
已采纳

EXTJs3.2 如何在选择文件后,将文件名获取放textfield中? 谢谢!

EXTJs3.2 如何在选择文件后,将文件名获取放textfield中?
图片说明

 Ext.onReady(function() {

            Ext.QuickTips.init();
            Ext.form.Field.prototype.msgTarget = 'side';


            var boardName = new Ext.form.TextField({
                  fieldLabel: '文件名',
                  width: 200,
                  xtype: 'textfield',
                  id: 'boardName'
            })

            var boardRevision = new Ext.form.TextField({
                  fieldLabel: '文件类型',
                  width: 200,
                  xtype: 'textfield',
                  id: 'boardRevision'
            })

/*          var zipField = new Ext.data.Field({
                xtype : 'field',
                fieldLabel : '选择文件 ',
                allowBlank : false,
                inputType : 'file',
                name : 'file',
                emptyText : 'No file selected'
            })*/

            var fm = new Ext.FormPanel({
                        // url : 'uploadController.jsp?t=' + new Date(),
                    renderTo : Ext.getBody(),   
                    layout : 'form',
                    title : 'CAD Upload',
                    height : 350,
                    width : 580,
                    padding : '20',
                    closeAction : 'hide',
                    plain : true,
                    autoScroll : true,

                    defaults:{
                        width:180
                        ,allowBlank:false               
                        ,blankText:'该项不能为空!'  
                    },

                    items : [boardName,{
                                    xtype : 'box',
                                    height : '30'
                                },boardRevision,{
                                    xtype : 'box',
                                    height : '30'
                                },{
                                    xtype : 'field',
                                    fieldLabel : 'Zip File ',
                                    allowBlank : false,
                                    inputType : 'file',
                                    name : 'file',
                                    emptyText : 'No file selected'
                                }],         // Ext.getCmpId("fieldID").getValue();

                        buttons : [{
                                    text : '开始上传',
                                    handler : function() {
                                        if (fm.form.isValid()) { 
                                            Ext.MessageBox.show({
                                                        title : '正在上传文件',
                                                        width : 240,
                                                        progress : true,
                                                        closable : false,
                                                        buttons : {
                                                            cancel : 'Cancel'
                                                        }
                                                    });
                                            fm.getForm().submit();
                                        } else {
                                            Ext.Msg.alert("消息","请先选择文件再上传.");
                                            fm.form.reset();

                                        }
                                    }
                                }]
                    });

        });
  • 写回答

2条回答

  • Go 旅城通票 2016-02-03 09:28
    关注
               , {
                    xtype: 'field',
                    fieldLabel: 'Zip File ',
                    allowBlank: false,
                    inputType: 'file',
                    name: 'file',
                    listeners: {
                        change: function () {////////
                            var m = /\\([^\\]+)$/.exec(this.getValue())[1];
                            Ext.get('boardName').dom.value = m;
                            Ext.get('boardRevision').dom.value = m.split('.')[1] || '';
                        }
                    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退
  • ¥20 win系统的PYQT程序生成的数据如何放入云服务器阿里云window版?