الحصول على القيم الحقلية من sitemapnode عند الحصول على عناصر من portalsitemprovider

sharepoint.stackexchange https://sharepoint.stackexchange.com//questions/92529

سؤال

أحاول الاستعلام عن قائمتي باستخدام portalsitemprovider.هنا رمزي: giveacodicetagpre.

يمكنني الحصول على عمود العنوان من عنصر قائمة واحدة.لكنني لا أعرف كيفية الحصول على حقول أخرى في القائمة.دعنا نقول أن لدي عمود يدعى "العمر".أين هو في sitemapnode؟

أي فكرة؟

هل كانت مفيدة؟

المحلول

I saw a Demo in CodePlex at : http://spquerydemo.codeplex.com . It presents an extensive sample code for many ways of querying SharePoint.

I've found the solution.

This Code Works like a BOOM. Instead of "SiteMapNode" object you need "PortalListItemSiteMapNode" for indexer to work.

public List<string> GetChachedItems(string webUrl, SPQuery query)
    {
        SiteMapNodeCollection nodeCollection = new SiteMapNodeCollection();
        PortalSiteMapProvider portalProvider = PortalSiteMapProvider.WebSiteMapProvider;
        PortalWebSiteMapNode webNode = ((PortalSiteMapNode)portalProvider.CurrentNode).WebNode;
        if (webNode != null)
        {
            nodeCollection = portalProvider.GetCachedListItemsByQuery(
                webNode, "test", query, SPContext.Current.Web);
        }
        List<string> itemCollection = new List<string>();

        var listItemNodes = portalProvider.GetCachedListItemsByQuery(
                    webNode,
                    "Test", query, SPContext.Current.Web);

        foreach (PortalListItemSiteMapNode node in nodeCollection)
        {
            itemCollection.Add(node.Title + " " + node["age"]);
        }
        return itemCollection;
    }

نصائح أخرى

You can use Item property of SiteMapNode to gets or sets a custom attribute from the Attributes collection or a resource string based on the specified key!

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى sharepoint.stackexchange
scroll top