SharePoint:过滤包含文件夹的列表

发布于 2024-07-19 02:53:57 字数 953 浏览 3 评论 0原文

我有一个 SharePoint 文档库,它具有用于组织文档的文件夹结构(还用于通过文件夹权限控制访问)。

库中的文档每月都会更新,我们将每个月版本的文档存储在同一个文件夹中; 有一个用于过滤的“月份”列,其中包含诸如 Jan 09、Feb 09 等值。它看起来像这样:

    Title                  Month
    -----                  -----
    SubFolder 1
    SubFolder 2
[]  Interesting Facts      Jan 09
[]  Interesting Facts      Feb 09
[]  Interesting Facts      Mar 09
[]  Fascinating Numbers    Jan 09
[]  Fascinating Numbers    Feb 09
    ...

现在,因为用户通常对“当前”月份最感兴趣,所以我希望他们是能够应用过滤器,并选择(例如)Mar 09。但是,如果他们使用内置过滤来执行此操作,它也会过滤掉文件夹,并且他们无法再导航文件夹层次结构。 这不好——我希望他们能够在过滤器完好无损的情况下在文件夹之间移动,这样他们就不需要不断地关闭和打开它。

我想我也许可以使用自定义视图(选择类型=文件夹或月份=[月]),并且在一定程度上确实有效。 但是,我只能让它在固定月份内工作,而我需要用户能够选择月份 - 也许通过页面上的下拉控件(而且我不这样做)我想在 5 年的时间里创建 60 个视图,也不希望每个月都创建一个新视图)。

我认为可以在代码中创建视图(而不是通过 UI),但我无法弄清楚如何将动态值(特定于用户的设置)获取到 CAML 查询中。

任何指点不胜感激! 顺便说一句,我知道认为文件夹是不好的,一切都应该只是一个列表。 然而,在考虑了替代方案之后,我仍然倾向于使用文件夹 - 如果我可以解决这个问题。

提前致谢。

I have a SharePoint document library that has a folder structure used for organizing the documents (but also for controlling access, via permissions on the folders).

The documents in the library are updated every month, and we store every month's version of the document in the same folder; there's a "month" column used for filtering that will contain values like Jan 09, Feb 09, etc. It looks like this:

    Title                  Month
    -----                  -----
    SubFolder 1
    SubFolder 2
[]  Interesting Facts      Jan 09
[]  Interesting Facts      Feb 09
[]  Interesting Facts      Mar 09
[]  Fascinating Numbers    Jan 09
[]  Fascinating Numbers    Feb 09
    ...

Now, because users will generally be most interested in the 'current' month, I'd like them to be able to apply a filter, and select (say) Mar 09. However, if they do this using the built-in filtering, it also filters out the folders, and they can no longer navigate the folder hierarchy. This is no good - I want them to be able to move between folders with the filter intact, so that they don't need to keep switching it off and on again.

I figured I might be able to use a custom view (selecting where type=folder or month=[month]), and to an extent that does work. However, I can only get it to work for a fixed month, whereas I need the user to be able to select the month - perhaps via a drop-down control on the page (and I don't want to create 60 views for 5 years' worth of months, nor do I want to have to create a new view every month).

I thought it might be possible to create a view in code (rather than via the UI), but I've not been able to figure out how to get a dynamic value (a user-specific setting) into the CAML query.

Any pointers gratefully appreciated! And by the way, I am aware of the dogma that folders are bad, and that everything should just be a list. However, having considered the alternatives, I still favour using folders - if I can solve this problem.

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

赠意 2024-07-26 02:53:57

您能否创建一个继承自包含“月份”列的文件夹的内容类型? 然后,将此列表中的普通文件夹内容类型替换为新的内容类型。 适当设置月份,现在您的过滤器也将包含该文件夹。

Could you create a content type that inherits from Folder that contains a Month column? Then, replace the normal folder content type with your new one on this list. Set the month appropriately, and now your filter would contain the folder as well.

难得心□动 2024-07-26 02:53:57

您可能想尝试使用 DataViewWebpart 由表单 Web 部件过滤 来执行此操作。
管理文件夹的显示以及单击时的文件夹项目将是一个问题。 我想这就是不使用文件夹的原因之一。

You might like to try using a DataViewWebpart filtered by a form webpart to do this.
Managing the display of the folders and then the folders items when it is clicked on will be a problem. That is one of the reasons for not using folders I guess.

笑饮青盏花 2024-07-26 02:53:57

我目前遇到了完全相同的问题,我需要根据文件夹名称进行过滤,然后在页面上显示这些文件夹,而不是简单的日期。 单击文件夹后,他们将能够查看该文件夹的内容。

我还没有找到一个好的解决方案,但对于您来说,您应该能够使用 contentQueryWebpart 简单地创建自定义 CAML 查询。

像这样的事情:
进一步自定义 CQWP

但您将在文件夹的日期/时间上执行此操作,而不是其他任何操作。

您的查询类似于:

 <![CDATA[
    <Where>
     <Gt>
       <FieldRef Name="Created" Nullable="True" Type="DateTime"/>
       <Value Type="DateTime"><Today /></Value>
     </Gt>
   </Where>
   <OrderBy>
       <FieldRef Name="Created" Nullable="True" Type="DateTime"Ascending="FALSE"/>
   </OrderBy>]]>

我还会添加您要查找的文件夹的名称,以确保不会返回任何其他内容。

希望这可以帮助。 如果您找到其他解决方案,请回发。

I'm currently experiencing the exact same issue, instead of a simple date, I need to filter based on folder names and then then show those folders on the page. Once they click a folder they will then be able to view the content of that folder.

I haven't found a good solution for this just yet, but for yours, you should be able to simply create a custom CAML query using the contentQueryWebpart.

Something like this:
Further Customize CQWP

But you would do it on the date/time of the folder and nothing else.

Your query would be something like:

 <![CDATA[
    <Where>
     <Gt>
       <FieldRef Name="Created" Nullable="True" Type="DateTime"/>
       <Value Type="DateTime"><Today /></Value>
     </Gt>
   </Where>
   <OrderBy>
       <FieldRef Name="Created" Nullable="True" Type="DateTime"Ascending="FALSE"/>
   </OrderBy>]]>

I would add also the name of the folder you're looking for to make sure nothing else gets returned.

Hope this helps. And please do postback if you find another solution.

落叶缤纷 2024-07-26 02:53:57

我想我找到了你的解决方案 - DataWebPart 实际上帮助了我......

使用它也让我大开眼界:
ASP. NET 控件过滤数据视图

总结一下,您只需使用月年组合填充下拉列表,通过设计器视图在页面上添加共享文档库,使用“过滤器”连接到 ASP.NET 下拉列表很快你每个月就会有一个过滤器。
您还可以使用 XSL 将其默认为某个日期,现在一切都在代码视图中:)

I think I found your solution - The DataWebPart is actually what helped me....

Using this also was a huge eye opener:
ASP.NET Controls Filter Data View

To summarize it, you can simply populate your dropdown with the month year combo, add the shared Doc library on the page via the designer view, use a 'filter' connection to your ASP.NET dropdown and pronto you have a filter on a per month.
You can also have it default to a certain date using XSL, it's all in the code-view now :)

蝶…霜飞 2024-07-26 02:53:57

@加里
数据视图的控制过滤器(我的第二个答案)实际上确实保留了文件夹层次结构。

如果需要,您可以将其放入子文件夹中,但在您的情况下,您只想正确显示一个特定文件夹?

你正在做的是使用 SP-designer 来完成它,我找不到通过常规 Web 部件来完成它的方法。

  1. 将共享文档库拖放到页面的“设计”视图中
  2. 单击常见任务箭头 ( > ) 并自定义要显示的列
  3. 仍然在常见任务中,应用选择的过滤器。 您想要在此处执行的操作是在“月份”列上应用过滤器,以便“月份”列等于当前月份/年份,对吗?
    该过滤器只会让您选择输入内容,输入当前月份,例如 5 月 9 日。然后切换到“代码”视图
  4. 查找共享文档库,更具体地查找类似以下内容:
    <Where>.... 这就是我之前提到的 CAML 查询。 您可以对整个内容进行 HTML 解码,以便它更具可读性。
    但本质上,过滤器是一个简单的 CAML 查询。
    您想要修改该查询,以便您的月/年组合是当前月/年的组合。
    CAML 有一个称为的功能。 它以以下格式返回月份:mm/yyyy(您可能需要更改列上的格式或创建一个新的格式以方便自己使用)-您的 CAML 查询应该有点像这样:

<Where>
 <Eq>
   <FieldRef Name='Month'/>
   <Value Type='Number'><Month/></Value>
 </Eq>
</Where>


html 编码:


<Where><Eq><FieldRef 名称='月份'/><值类型='数字'><月份/></Where>

关键是您仅在数据视图的根级别创建过滤器。 一旦他们单击该文件夹,他们就会被放入文档库中,并且可以查看该文件夹中的所有内容。

希望这有帮助!

ps:在编码的html上,我必须在“;”之前添加空格 这样你就可以看到代码了。

@Gary
The Controls filter of the DATA view (my 2nd answer) actually does keep the folder hierarchy.

You can have it go into sub-folders if needed, but in your case you're only interested in showing one specific folder correct?

What you're doing is useing SP-designer to do it, I couldn't find a way to do it via the regular webparts.

  1. drag and drop your shared document library in the 'design' view for the page
  2. Click the common task arrow ( > ) and customize the columns you want to show
  3. Still in the common task, apply a filter of choice. What you want to do here is apply a filter on your Month column, so that the Month column is equal to the current month/year, correct?
    The filter will only give you a choice to type something in, type the current month, say May 09. then switch to 'code' view
  4. Find the shared document library, and more specifically look for something like:
    < ;Where> ;.... That is the CAML query I had mentioned before. You can do an HTML decode on the whole thing, so that it's a bit more readable.
    But in essence, the filter is a simple CAML query.
    You want to modify that query, so that your month/year combo is that of the current month/year.
    CAML has one feature called <MONTH/> which returns the month in the following format: mm/yyyy (you may need to change the format on your column or create a new one to make it easy on yourself) - Your CAML query should be something a bit like this:

<Where>
 <Eq>
   <FieldRef Name='Month'/>
   <Value Type='Number'><Month/></Value>
 </Eq>
</Where>

or
html encoded:


< ;Where> ;< ;Eq> ;< ;FieldRef Name='Month'/> ;< ;Value Type='Number'> ;< ;Month/> ;< ;/Value> ;< ;/Eq> ;< ;/Where> ;

The key to this, is that you're only creating a filter at the root level, on the data view. Once they click on the folder, they're just thrown into the document library and can view everything within the folder.

Hope this help!

ps: on the html encoded I had to add spaces before the ';' so you could see the code.

你的背包 2024-07-26 02:53:57

我在过滤和 SPGridView 方面做了很多工作。 也许你可以从这篇帖子中得到一些东西我的我的博客。
正如我所说,不知道它是否对您有帮助,但看看吧。

I have worked a great deal with filtering and the SPGridView. Maybe you can get something out of looking into this post on my my blog.
As I said, don´t know if it will help you but have a look.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文