首页 > 代码库 > sharepoint ECMA using a list template to creating a list in SubSIte
sharepoint ECMA using a list template to creating a list in SubSIte
Using a list template to creating a list in SubSIte
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | function CreateList(){ var clientContext = new SP.ClientContext(siteUrl); var currentWeb = clientContext.get_web(); var listTemplateCollection = currentWeb.get_listTemplates(); clientContext.load(listTemplateCollection); clientContext.executeQueryAsync( Function.createDelegate( this , onQuerySucceededlistTemplate), Function.createDelegate( this , onQueryFailedlistTemplate) ); }<br> function onQuerySucceededlistTemplate() { var listTemplateEnumerator = listTemplateCollection.getEnumerator(); var listtemplateInfo = "" ; while (listTemplateEnumerator.moveNext()) { var listTemp = listTemplateEnumerator.get_current(); if (listTemp.get_name() == "OfficeDocument_List" ) { var count = subWebs.get_count(); if (count > 0) { for ( var i = 0; i < count; i++) { var subWeb = subWebs.itemAt(i); if (subWeb.get_serverRelativeUrl() == self.selectedSiteName()) { var listCreateInfo = new SP.ListCreationInformation(); listCreateInfo.set_title(self.DocumentName()); listCreateInfo.set_description(self.DocumentDescription()); listCreateInfo.set_templateType(listTemp.get_listTemplateTypeKind()); listCreateInfo.set_templateFeatureId(listTemp.get_featureId().toString()); oList = subWeb.get_lists().add(listCreateInfo); clientContext.load(subWeb); clientContext.load(oList); clientContext.executeQueryAsync( Function.createDelegate( this , ExecuteOnSuccessList), Function.createDelegate( this , ExecuteOnFailureList) ); } } } } } }<br><br>1.此处需要注意的是,必须通过主站点查找到下面的子站点,只有这样才能通过custom list template 创建成功list<br>2.创建list的必须设置featureID:listCreateInfo.set_templateFeatureId(listTemp.get_featureId().toString());<em id= "__mceDel" >否则会创建不成功,并且报一个Invaild contentType Name错误.</em> |
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。