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 opencv 无法读取视频
  • ¥15 用matlab 实现通信仿真
  • ¥15 按键修改电子时钟,C51单片机
  • ¥60 Java中实现如何实现张量类,并用于图像处理(不运用其他科学计算库和图像处理库))
  • ¥20 5037端口被adb自己占了
  • ¥15 python:excel数据写入多个对应word文档
  • ¥60 全一数分解素因子和素数循环节位数
  • ¥15 ffmpeg如何安装到虚拟环境
  • ¥188 寻找能做王者评分提取的
  • ¥15 matlab用simulink求解一个二阶微分方程,要求截图