带有 caml 和 xslt 的共享点 Web 部件
我如何创建一个访问列表并可以应用 CAML 的共享点 Web 部件。
需要 CAML 来显示仅返回具有“Position”>“字段”的列表项。 0
我还需要 webpart 来应用 xslt。
How can i create a sharepoint webpart that accesses a List, and that can have CAML applied to it.
The CAML is needed to display return only list items that have the field with "Position" > 0
i also need the webpart to have xslt applied to that.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要将内容查询 Web 部件添加到您的页面(注意:需要 MOSS,而不是免费的 WSS)。 这允许您查询数据并对其应用 XSL 转换。
Web 部件允许您查询特定网站集、Web 或列表。 然后,您可以设置参数以返回某种类型的数据并应用过滤器、排序和分组。 您还可以选择希望如何显示数据,该数据以选项下拉列表的形式向最终用户显示。 这些选项中的每一个都由 XSL 转换提供支持。
Heather Solomon 的这篇博文是帮助您获得最佳资源的最佳资源之一首先介绍如何创建您自己的转换并配置 CQWP。 它还解释了如何确保您需要的所有字段都传递到 XSLT(默认情况下,这只发生在一小部分字段中)。
更新:
仅返回字段“Position”> 的列表项。 0 中,在 XSLT 中执行此操作也是最简单的。 您必须已将 Position 字段添加到 CommonViewFields 中,以便将其传递到 XSLT。 然后在您的自定义项目样式中(如果您关注 Heather 的帖子,则在 ItemStyle.xsl 中)添加以下内容:
当“Position”<= 0 时,这会隐式忽略。
You need to add the Content Query Web Part to your page (note: requires MOSS not free WSS). This allows you to query your data and apply an XSL transform to it.
The web part allows you to query a particular site collection, web or list. You can then set parameters to return data of a certain type and apply filters, sorting and grouping. You can also choose how you wish the data to be displayed which appears to the end user as a dropdown list of options. Each of these options is powered by an XSL transform.
This blog post by Heather Solomon is one of the best resources to help you get started with how to create your own transform and configure the CQWP. It also explains how to ensure all the fields you need are passed through to the XSLT (by default this only happens for a small subset).
Update:
To only return list items where the field "Position" > 0, it is simplest to do this within XSLT as well. You must have added the Position field to CommonViewFields so that it gets passed through to the XSLT. Then in your custom item style (in ItemStyle.xsl if you follow Heather's post), add the following:
This implicitly ignores when "Position" <= 0.
我同意 Alex 的观点,即如果可能的话,内容查询 Web 部件 (CQWP) 是最佳选择。
但是,如果您想进入代码,您可以执行如下操作。 困难的部分是将其转换为 XML,尽管可能有一种简单的方法可以将其转换为某些非自定义(尽管丑陋)形式的 XML。
如果您不想使用现有视图,则需要手动设置 SPQuery 对象; 将其 ViewFields、Query 和 RowLimit 设置为最小值。 您可以使用CAML 查询工具来帮助您完成此操作。
I agree with Alex, that the Content Query Web Part (CQWP) is the way to go if possible.
However, if you want to get into the code you can do something like the following. The rough part is getting it into XML, although there may be an easy way to get it into some non-custom (albeit ugly) form of XML.
If you don't want to use an existing view, you will need to set up the SPQuery object by hand; setting its ViewFields, Query, and RowLimit at a minimum. You can use the a CAML Query Tool to help you with this.