簡體   English   中英

sp.js按內容類型獲取所有列表

[英]sp.js get all lists by content type

我已經梳理了sp名稱空間文檔,但沒有發現太多需要做的事情。

我從http://www.c-sharpcorner.com/Blogs/12134/how-to-get-the-list-content-types-using-csom-in-sharepoint-2.aspx找到了此代碼段

          //// String Variable to store the siteURL
        string siteURL = "http://c4968397007/";

        //// Get the context for the SharePoint Site to access the data
        ClientContext clientContext = new ClientContext(siteURL);

        //// Get the content type collection for the list "Custom"
        ContentTypeCollection contentTypeColl = clientContext.Web.Lists.GetByTitle("Custom").ContentTypes;

        clientContext.Load(contentTypeColl);
        clientContext.ExecuteQuery();

        //// Display the Content Type name
        foreach (ContentType ct in contentTypeColl)
        {
            Console.WriteLine(ct.Name);
        }
        Console.ReadLine();

這將獲得一個特定的列表內容類型。

我的想法是獲取所有列表,然后獲取其所有內容類型,然后使用其ID /標題查詢列表中的數據。
在顯示模板中似乎要做很多工作。

我是在正確的道路上還是我缺少什么? 有沒有sp wiz在意新的search / js架構?

您可能要使用JavaScript庫,例如SharepointPlus或流行的SPServices

我認為SharepointPlus的語法更簡單,代碼類似於:

$SP().lists(function(list) {
  for (var i=0; i<list.length; i++) {
    // list[i]['Name'] contains the name of the list
    $SP().list(list[i]['Name']).get(/* something */)
  }
});

您說了一些有關內容類型的內容。 因此,您可能還需要查看info()函數並檢查名稱為“ ContentTypeId”的字段。

僅供參考,我創建了這個SharepointPlus庫。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM