Extjs上传导入数据前端(二)

46 篇文章 0 订阅
36 篇文章 1 订阅

 创建Extjs表格省略......

 var fileImport;
    var uploadForm = new Ext.FormPanel({
        id: 'uploadForm',
        width: 320,
        frame: true,
        fileUpload: true,
        autoHeight: true,
        labelWidth: 30,
        enctype: 'multipart/form-data',
        defaults: {
            anchor: '83%',
            allowBlank: true
        },
        items: [{
            xtype: 'fileuploadfield',
            emptyText: '请选择上传文件...',
            fieldLabel: '文件',
            id: 'uploadFile',
            name: 'upload',
            allowBlank: false,
            blankText: '文件名称不能为空.',
            buttonCfg: {
                text: '选择...',
                hidden: true
            }
        }],
        buttons: [{
            text: '导入',
            handler: function() {
                if (uploadForm.getForm().isValid()) {

                    uploadForm.getForm().submit({
                        url: "xxx.action",
                        method: 'POST',
                        waitTitle: '请稍后',
                        waitMsg: '正在导入文档 ...',
                        success: function(fp, action) {
                            uploadForm.getForm().reset();
                            sensitiveWordsLightGrid.refresh();
                            fileImport.hide();
                        },
                        failure: function(fp, action) {
                            fileImport.hide();
                        }
                    });
                }
            }
        }, {
            text: '重置',
            handler: function() {
                uploadForm.getForm().reset();
            }
        }, {
            text: '选择文件',
            handler: function() {
                $('#uploadFile-file').click();
            }
        }]

    });
    $("#import").click(function() {
        fileImport = new Ext.Window({
            title: '批量导入',
            width: 300,
            height: 100,
            autoHeight: true,
            border: false,
            plain: true,
            modal: true,
            layout: 'fit',
            maximizable: false, // 禁止最大化
            closeAction: 'hide',
            closable: true, // 是否有关闭
            collapsible: true, // 可折叠
            iconCls: 'bind',
            items: [uploadForm]
        });
        fileImport.setPosition(308, 260);
        fileImport.show(this);
    });
    

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值