具有同一字段的多个值的 SharePoint 筛选列表

Mar*_*o C 4 url sharepoint

“显示列表中属于健康或娱乐类别的项目。”

我有一个示例列表: http://www.example.com/Lists/MyList/AllItems.aspx

如果我要过滤列表项以查找值为“娱乐”的类别,则 URL 将如下所示:

http://www.example.com/Lists/MyList/AllItems.aspx?View={ViewId}&FilterField=Categories&FilterValue=Entertainment

假设我想按类别为“娱乐”或“健康”的列表项进行过滤。不幸的是,此 URL 不起作用,因为我一次只能为同一字段过滤 1 个值:

http://www.example.com/Lists/MyList/AllItems.aspx?View={ViewId}&FilterField1=Categories&FilterValue1=Entertainment&FilterField2=Categories&FilterValue2=Health

使用 SharePoint 列表中相同字段的多个值(“OR”条件)进行过滤的 URL 是什么?

Ste*_*sta 5

您将要使用的名称/值对FilterName,并FilterMultiValue在您的查询字符串以达到或过滤器。

例如,要过滤 SharePoint 团队网站中的标准任务列表视图以返回“已完成”或“已延迟”的所有项目,您的 URL 应如下所示:

http://www.example.com/Lists/MyList/AllItems.aspx?View={ViewId}&
FilterName=Status&FilterMultiValue=Completed;Deferred
Run Code Online (Sandbox Code Playgroud)

在您的用例中,新 URL 将是:

http://www.example.com/Lists/MyList/AllItems.aspx?View={ViewId}&
FilterName=Categories&FilterMultiValue=Entertainment;Health
Run Code Online (Sandbox Code Playgroud)

更新:不幸的是,Microsoft 在记录诸如在 SharePoint 中工作的查询字符串参数之类的内容方面做得并不好。我什至不记得我是从哪里第一次拿起它的(有时您会看到本机 Web 部件在做某事并自己尝试),但自 SP2007 以来我一直在成功使用。这是 2012 年的一篇博文,解释了同样的事情并提供了更多示例:http : //techtrainingnotes.blogspot.com/2012/03/sharepoint-search-filter-or-sort-lists.html