文档详情

Sharepoint学习笔记—ECMAScript对象模型系列-- 10、 复制移动Document List中的文档.docx

发布:2017-12-18约5.79千字共11页下载文档
文本预览下载声明
使用ECMAScript对象模型,我们可以实现对DocumentList中Files的拷贝或移动。在这里,我们需要实现的的效果是当选中某个Document List中的文档时,在其关联Ribbon区出现一个按钮,点击此按钮,可以实现把这个选中的文档复制或移动到另一个Document List中。 效果图如下:? 这里我们在代码中指定了目标Document List的名字,而在实际操作中,你可以在点击按钮后弹出模态窗口,让用户自行选择或输入目标Document List的名字,以增强灵活性。?一、复制功能的实现?直接进入步骤?1、新建一个Sharepoint空项目,命名为ECMAscriptCopyFile??2、在此项目中添加新的Feature,并命名为ECMAscriptCopyFileFeature?命名此Feature: ?3、在此项目中添加Images与Layouts两个Sharepoint目录。?拷贝一个文件拷贝的图片放到Images\ECMAscriptCopyFile\目录下,并命名为copyFile.png以备用。??4、添加一个新的空Element,命名为ECMAscriptCopyFileElement.并定义此元素的代码??xml?version=1.0?encoding=utf-8?Elements?xmlns=/sharepoint/?CustomAction?Id=CopyingFilesButton?Location=CommandUI.Ribbon?RegistrationId=101?RegistrationType=List?Title=Copy?Documents?CommandUIExtension?CommandUIDefinitions?CommandUIDefinition?Location=Ribbon.Documents.Manage.Controls._children?Button?Id=Ribbon.Documents.Manage.CopyDocuments?Command=Ribbon.Documents.Manage.CopyDocuments.CopyFileCommand?LabelText=Copy?Documents?Image32by32=/_layouts/Images/ECMAscriptCopyFile/copyFile.png?TemplateAlias=o1?/?/CommandUIDefinition?/CommandUIDefinitions?CommandUIHandlers?CommandUIHandler?Command=Ribbon.Documents.Manage.CopyDocuments.CopyFileCommand?CommandAction=javascript:CopyDocumentListFile()/?/CommandUIHandlers?/CommandUIExtension?/CustomAction?CustomAction?Id=Ribbon.Documents.Manage.CopyDocuments.Script?Location=ScriptLink?ScriptSrc?=/_layouts/ECMAscriptCopyFile/ECMAcopyFile.js//Elements 在此元素中: 我们设置了按钮的放置位置在Ribbon.Documents.Manage.Controls 设置了引用外部Javascript文件ECMAcopyFile.js 设置了按钮的Action是调用Javascript文件中的CopyDocumentListFile()函数 要注意CommandUIDefinition中的Button的Command属性必须与CommandUIHandlers中的Command属性命名一致,表示对应的命令设置,响应对应的Button事件。?5、在Layouts的ECMAscriptCopyFile目录下新建一个名为ECMAcopyFile.js的Javascript文件。文件内容如下var?ECMACopyFile;var?ECMACopycontextvar?ECMACopyweb;var?ECMACopy_destinationlib;var?notifyId;function?CopyDocumentListFile()?{?ECMACopycontext?=?SP.ClientContext.get_current();?ECMACopyweb?=?ECMACopycontext.get_web();?ECMACopycontext.load(ECMACopyweb);?EC
显示全部
相似文档