加载消息,直到copyto()复制所有文档. [英] Loading message until copyto() copies all documents.

查看:56
本文介绍了加载消息,直到copyto()复制所有文档.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要通过单击按钮将文档从一个文档库复制到另一个文档库,大约20个文档,而且尺寸很大.
当我单击它时,它仅复制了很少的文档,而剩下的仅剩其他文档,我需要添加正在加载..."消息,直到所有文档都被复制为止.请帮助,因为它会跳过要复制的文档 每次 .

I need to copy the documents from one document library to another on a button click, i've  approximately 20 documents and big in size.
when i click it copies only few documents and left others, i need to add 'loading...' message until all documents are copied. Please help as it skips documents to be copied every time.

谢谢

Thanks,

莫希特·贾因(Mohit Jain)

Mohit Jain

推荐答案

要在复制文件时添加加载消息,我们可以像下面那样执行SP.UI.Notify.addNotification函数,在for循环中添加消息:

To Add loading message when copying files, we can  SP.UI.Notify.addNotification function to do it like below, add message in the for loop:

function CopyFiles()
{ 
 var filearray=docarray.split('


'); var ctx,file,notifyId; ctx =新的SP.ClientContext.get_current(); ctx.executeQueryAsync( 功能(发送方,参数){ //向用户设置要复制文件的通知. notifyId = SP.UI.Notify.addNotification('正在复制文件...',true); for(i = 0; i<(filearray.length)-1; i ++) { 调试器; 文件= ctx.get_web().getFileByServerRelativeUrl(filearray [i]); ctx.load(file); var fileparts = filearray [i] .split('/'); var filename = fileparts [(fileparts.length)-1] //文件已加载.现在我们要复制文件.我们将使用嵌套的AJAX调用 file.copyTo("/sites/TestSC/TestDestLib/" +文件名,true); } ctx.executeQueryAsync( 功能(发送方,参数){ //文件复制成功! SP.UI.Notify.removeNotification(notifyId); //让用户知道操作成功 SP.UI.Notify.addNotification('文件复制成功',false); }, 功能(发送方,参数){ //无法复制文件. SP.UI.Notify.removeNotification(notifyId); showError(args.get_message()); }); } , 功能(发送方,参数){ //无法找到文件. SP.UI.Notify.removeNotification(notifyId); showError(args.get_message()); }); }
'); var ctx, file, notifyId; ctx = new SP.ClientContext.get_current(); ctx.executeQueryAsync( function (sender, args) { // Set a notification to the user that we are going to copy the file. notifyId = SP.UI.Notify.addNotification('Copying files...', true); for(i=0;i<(filearray.length)-1;i++) { debugger; file = ctx.get_web().getFileByServerRelativeUrl(filearray[i]); ctx.load(file); var fileparts= filearray[i].split('/'); var filename= fileparts[(fileparts.length)-1] // File loaded. Now we want to copy the file. We'll use a nested AJAX call file.copyTo("/sites/TestSC/TestDestLib/"+filename, true); } ctx.executeQueryAsync( function (sender, args) { // File copied successfully! SP.UI.Notify.removeNotification(notifyId); // Let the user know that the operation was successful SP.UI.Notify.addNotification('Files copied successfully', false); }, function (sender, args) { // Unable to copy file. SP.UI.Notify.removeNotification(notifyId); showError(args.get_message()); }); } , function (sender, args) { // Unable to locate file. SP.UI.Notify.removeNotification(notifyId); showError(args.get_message()); }); }

更多信息:

在SharePoint中显示/隐藏通知

谢谢

最好的问候


这篇关于加载消息,直到copyto()复制所有文档.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆