使用SPServices在sharepoint2010中读写列表数据
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用SPServices在sharepoint2010中读写列表数据相关的知识,希望对你有一定的参考价值。
Just syntax examples here. First block reads, second writes. Top function just a debugging helper.Using jquery 1.5, $(xData.responseXML).find("nodeName=z:row]").each(function(i)... may need to be written as
$(xData.responseXML).find("nodeName='z:row']").each(function(i)... with single quotes around 'z:row'.
function printObject(o){ var output = ''; for (property in o) { output += property + ': ' + o[property]+'; '; } alert(output); } function readThenWrite(){ $().SPServices({ operation: "GetListItems", webURL: "/sitepath", /*optional parameter used if list lives in parent site */ async: false, listName: "Badge Achievements", /*name of the list */ viewName: '{D6ED584C-4673-4B89-B539-FF43D936ABC9}',/*optional to specify view */ CAMLRowLimit: 4, /*optional to limit results */ CAMLQuery: '<Query><Where><Eq><FieldRef Name="Author" /><Value Type="User">' + userName + '</Value></Eq></Where></Query>', completefunc: function (xData, Status) { //printObject(xData); $(xData.responseXML).find("[nodeName=z:row]").each(function(i) { arrBadgesAchvd[i] = $(this).attr('ows_Badge').split("#")[1]; }); } });/*-End SpServices*/ $().SPServices({ operation: "UpdateListItems", async: false, listName: "Learning Path Completion", updates: "<Batch OnError='Continue'>" + "<Method ID='1' Cmd='Update'>" + "<Field Name='Title'>percDone</Field>" + "<Field Name='User'>" + userID + "</Field>" + "<Field Name='Completed'>" + lpdone + "</Field>" + "<Field Name='Total'>" + lptotal + "</Field>" + "<Field Name='ID'>" + docid + "</Field>" + "</Method>" + "</Batch><Where></Where>", completefunc: function(xData, Status) {} });//End SPSErvices }/*End readThenWrite*/
以上是关于使用SPServices在sharepoint2010中读写列表数据的主要内容,如果未能解决你的问题,请参考以下文章
SharePoint 2010使用SPServices获取用户标识
具有CAML查询的SharePoint级联下拉列表可过滤其中一个选项