├── README.md ├── jquery.getlist.js └── Home.aspx /README.md: -------------------------------------------------------------------------------- 1 | # spservices.js-example 2 | this is the jquery spservices.js example code that use the query 3 | 4 | # usage 5 | Host the Home.aspx and jquery.getlist.js into Sharepoint. 6 | -------------------------------------------------------------------------------- /jquery.getlist.js: -------------------------------------------------------------------------------- 1 | getMyListData(); 2 | $('#DeltaPageStatusBar').css('display', 'none'); 3 | 4 | function getMyListData() 5 | { 6 | var urls = window.location.pathname; 7 | var myPageName = urls.substring(urls.lastIndexOf('/') + 1).split(".",1)[0]; 8 | var method = "GetListItems"; 9 | var webURL = $().SPServices.SPGetCurrentSite() ; 10 | var list = "mylinks"; 11 | var fieldsToRead = ""+"" +""; 12 | var query = "" + myPageName + ""; 13 | var result=[]; 14 | var num=[]; 15 | var cat=[]; 16 | $().SPServices 17 | ({ 18 | operation: method, 19 | async: false, 20 | webURL: webURL, 21 | listName: list, 22 | CAMLViewFields: "", 23 | CAMLQuery: query, 24 | completefunc: function (xData, Status) 25 | { 26 | $(xData.responseXML).SPFilterNode("z:row").each(function() 27 | { 28 | var title = $(this).attr("ows_Title"); 29 | var pgname = $(this).attr("ows_Page_x0020_Name"); 30 | var category = $(this).attr("ows_Category"); 31 | var tmp = $(this).attr("ows_URL").split(",",2); 32 | var url=tmp[0]; 33 | var description=tmp[1]; 34 | 35 | if(!num[category]) num[category]=0; 36 | if(!result[category]) result[category]=new Array(); 37 | if(!cat[category]) cat[category]=category; 38 | 39 | result[category][num[category]]={'title':title, 'url':url, 'description':description}; 40 | 41 | num[category]++; 42 | }); 43 | 44 | for(x in cat){ 45 | 46 | var str="

"+x+"

"; 53 | $("#result_div").append(str); 54 | } 55 | } 56 | }); 57 | }; 58 | -------------------------------------------------------------------------------- /Home.aspx: -------------------------------------------------------------------------------- 1 | <%@ Assembly Name="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%> <%@ Page Language="C#" Inherits="Microsoft.SharePoint.WebPartPages.WikiEditPage" MasterPageFile="~masterurl/default.master" MainContentID="PlaceHolderMain" meta:progid="SharePoint.WebPartPage.Document" meta:webpartpageexpansion="full" %> 2 | <%@ Import Namespace="Microsoft.SharePoint.WebPartPages" %> <%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Import Namespace="Microsoft.SharePoint" %> <%@ Assembly Name="Microsoft.Web.CommandUI, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 3 | <%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 4 | 5 | - 6 | 7 | 8 | 9 | 10 | 11 | var navBarHelpOverrideKey = "WSSEndUser"; 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
--------------------------------------------------------------------------------