如何在SharePoint的列表中使用通配符来filter出ListItem?

一个朋友问我这样一个问题, 他想要快速从SharePoint的文档库中filter出来名字中先带有一个Q, 接着一些其他的字符, 后面再跟着有一个数字20这样的文件.

 

第一个想法就是修改SharePoint的ListView. 经过research, 确定ListView的filter中不能使用通配符(wildcard), 即诸如*, %之类.

 

第二个想法就是添加一个content editor webpart, 然后写脚本. 脚本最终要使用到CAML query来发送请求到SharePoint服务器来获得数据. 然而, CAML是不支持wildcard的. 这里Content Query WebPart也就一样不行了, 因为最终也还是要用到CAML Query.

如何使用Content Query Web Part中的CAML, 可以参考下文.

Embed CAML Queries into the Content Query Webpart - Finding Draft Publishing Content

http://the-north.com/sharepoint/post/Embed-CAML-Queries-into-the-Content-Query-Webpart-Finding-Draft-Publishing-Content

CAML不能用通配符的证明在下文中.

CAML Query - Wildcards or build dynamically?

http://social.technet.microsoft.com/Forums/sharepoint/en-US/feb630db-f54a-4f43-9513-ac14cb20c789/caml-query-wildcards-or-build-dynamically

Wildcard in CAML query

http://www.codeproject.com/Questions/138385/Wildcard-in-CAML-query

 

第三个想法就是建立一个Search Scope, 范围就在这个文档库上, 然后看搜索是不是可以使用通配符. 经过研究, Search支持通配符, 但是不能支持"名字里先有什么,接着再有什么"这样如此复杂的模式匹配.

 

最后, 我只好使用一个workaround了.

1. Export to Excel.

2. 点击column header->Text Filters –> Custom Filter…

image

3. 填写你的通配符模式.

image

4. 结果.

SNAGHTML6fca90f

 

虽然借助了excel, 实现也不那么纯SharePoint, 但好在比较容易用的吧. -_-||

 

参考资料

===================

一般都有哪些通配符, 可以看这里.

Using wildcard characters to refine filters

http://technet.microsoft.com/en-us/library/cc483078.aspx

 

一个很牛的帮助写SharePoint的CAML的工具.

SharePoint CAML Query Helper for 2007, 2010, and 2013

http://spcamlqueryhelper.codeplex.com/

原文地址:https://www.cnblogs.com/awpatp/p/3370648.html