`

Ext.ux.UploadDialog的使用

阅读更多
最近使用了Ext.ux.UploadDialog,现在总结一下:
1、导入Ext.ux.UploadDialog包
<link rel="stylesheet" type="text/css" href="<c:url value="/widgets/UploadDialog/css/Ext.ux.UploadDialog.css"/>">
		<script type="text/javascript" src="<c:url value="/widgets/UploadDialog/Ext.ux.UploadDialog.js"/>"></script>
		<script type="text/javascript" src="<c:url value="/widgets/UploadDialog/Ext.ux.UploadDialog.packed.js"/>"></script>
		
		<script type="text/javascript" src="<c:url value="/widgets/UploadDialog/locale/zh_CN.utf-8.js"/>"></script>

注意包中没有包含zh_CN.utf-8.js,自己可以进行中文化的
2、产生上传文件的对话框代码
function uploadSw(){ 
  var dialog = new Ext.ux.UploadDialog.Dialog({
  	url: 'swUpload.shtml?method=uploadFile',
  	reset_on_hide: false,
  	permitted_extensions:['gz'],
  	allow_close_on_upload: true,
  	upload_autostart: false,
  	title:'软件入库'
  });

  //dialog.show('show-button');
  dialog.show();
  dialog.on('uploadsuccess', onUploadSuccess);
}

function onUploadSuccess(dialog, filename, resp_data, record){
  // 回调函数代码
}

注意:提交时,默认提交的文件名是file 可以修改 post_var_name: 'fileName'修改
3、Ext.ux.UploadDialog中的其它事件函数[转载自http://wayfoon.iteye.com/blog/432541]
    * filetest - fires before file is added into the queue, parameters:
      dialog - reference to dialog
      filename - file name
      If handler returns false then file will not be queued.
    * fileadd - fires when file is added into the queue, parameters:
      dialog - reference to dialog
      filename - file name
    * fileremove - fires when file is removed from the queue, parameters:
      dialog - reference to dialog
      filename - file name
      record - file record
    * resetqueue - fires when upload queue is resetted, parameters:
      dialog - reference to dialog
    * beforefileuploadstart - fires when file as about to start uploading:
      dialog - reference to dialog
      filename - uploaded file name
      record - file record
      If handler returns false then file upload will be canceled.
    * fileuploadstart - fires when file has started uploading:
      dialog - reference to dialog
      filename - uploaded file name
      record - file record
    * uploadsuccess - fires when file is successfuly uploaded, parameters:
      dialog - reference to dialog
      filename - uploaded file name
      data - js-object builded from json-data returned from upload handler response.
      record - file record
    * uploaderror - fires when file upload error occured, parameters:
      dialog - reference to dialog
      filename - uploaded file name
      data - js-object builded from json-data returned from upload handler response.
      record - file record
    * uploadfailed - fires when file upload failed, parameters:
      dialog - reference to dialog
      filename - failed file name
      record - file record
    * uploadcanceled - fires when file upload canceled, parameters:
      dialog - reference to dialog
      filename - failed file name
      record - file record
    * uploadstart - fires when upload process starts, parameters:
      dialog - reference to dialog
    * uploadstop - fires when upload process stops, parameters:
      dialog - reference to dialog
    * uploadcomplete - fires when upload process complete (no files to upload left), parameters:
      dialog - reference to dialog
分享到:
评论
9 楼 zhanyuanwen1989 2015-04-02  
能告诉我怎么添加关闭事件吗?
8 楼 qixiaopeng 2011-01-24  
xiaoyuqi00 写道
请问楼主,

我这个怎么不调用回调函数啊?

还有,他怎么判断调用哪个回调函数?

可能存在两种情况:
1)版本兼容
2)回调函数没有被注册
7 楼 xiaoyuqi00 2010-12-24  
请问楼主,

我这个怎么不调用回调函数啊?

还有,他怎么判断调用哪个回调函数?
6 楼 qixiaopeng 2010-07-14  
zhangyongfeng 写道
为什么我会有这个错误?
‘x_buttons_upload.getEl()’is null or not an object
Ext.ux.UploadDialog.packed.js


谢谢 楼主 看看什么情况哈


当时我使用的ExtJS的版本是2.0的,我手头没有代码,猜测应该是版本的问题,我记得UploadDialog这个widget要与ExtJS版本对应的
5 楼 zhangyongfeng 2010-06-24  
为什么我会有这个错误?
‘x_buttons_upload.getEl()’is null or not an object
Ext.ux.UploadDialog.packed.js


谢谢 楼主 看看什么情况哈

4 楼 qixiaopeng 2010-05-05  
peteronline 写道
确实不错,学习啦,非常感谢!

不客气,共同学习共同进步
3 楼 qixiaopeng 2010-04-30  
hui_windows 写道
我导入了Ext.ux.UploadDialog包中的相关js和css,运行了您的代码,但什么也没显示,请问为什么啊,请楼主帮忙,我想用ext.ux.uploaddialog做一个批量文件上传。


最近比较忙,回复晚了。是否可以把你的代码贴上来,一起找问题阿?
2 楼 hui_windows 2010-04-20  
我导入了Ext.ux.UploadDialog包中的相关js和css,运行了您的代码,但什么也没显示,请问为什么啊,请楼主帮忙,我想用ext.ux.uploaddialog做一个批量文件上传。
1 楼 peteronline 2010-03-05  
确实不错,学习啦,非常感谢!

相关推荐

Global site tag (gtag.js) - Google Analytics