内容查询 Web 部件 - QueryOverride 时如何 OrderBy?

发布于 2024-08-26 16:04:50 字数 650 浏览 6 评论 0原文

当您重写内容查询 Web 部件的 QueryOverride 属性时,如何对项目进行排序?

我负责扩展内容查询 Web 部件的 Web 部件。此 Web 部件的 QueryOverride 属性已通过编程方式更改。目前,Web 部件无法按设计运行,因为它没有根据相应的字段对项目进行排序。

如果我将 节点添加到 QueryOverride 属性,我会收到一条错误消息,内容为“此 Web 部件的查询出现问题...”并且内容查询 Web 部件似乎没有我可以使用的 OrderBy 属性。

这篇 msdn 文章的“QueryOverride 属性”部分似乎建议我应该能够将 节点添加到 QueryOverride,但我读过的许多网站表明这不是真的。

那么,当您重写内容查询 Web 部件的 QueryOverride 属性时,如何对项目进行排序呢?

How do you order items when you override the QueryOverride property of the Content Query Web Part?

I have been given responsibility for a Web Part which extends the Content Query Web Part. The QueryOverride property of this Web Part is programmatically changed. Currently, the Web Part does not function as designed, as it does not order the items according to the appropriate field.

If I add an <OrderBy> node to the QueryOverride property I get an error message along the lines of 'something wrong with the query this web part is...' and the Content Query Web Part doesn't seem to have an OrderBy property which I could use instead.

The "QueryOverride property" part of this msdn article seems to suggest I should be able to add an <OrderBy> node to the QueryOverride but a number of web sites I've been reading suggest that this is not true.

So, how do you order items when you override the QueryOverride property of the Content Query Web Part?

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

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

发布评论

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

评论(2

难得心□动 2024-09-02 16:04:50

您的 QueryOverride 语句是否包含任何空格/换行符?我想我记得不久前有一种情况,其中 QueryOverride 需要全部包含在一行中,并且 xml 标记之间没有空格。

我知道很奇怪,但尝试一下。

另外,作为参考,请参阅 MSDN 页面上的第一个社区评论 http://msdn .microsoft.com/en-us/library/aa981241.aspx

Does your QueryOverride statement contain any Whitespace/linebreaks by any chance? I think I recall a while back having a situation where the QueryOverride needed to be all contained on one line, with no spaces between xml tags.

Weird I know, but try it out.

Also, for reference see the first community comment on the MSDN page http://msdn.microsoft.com/en-us/library/aa981241.aspx

神爱温柔 2024-09-02 16:04:50

谢谢你。需要澄清的是,标签之前或之后也不应该有空格。

这不起作用:

<![CDATA[
   <OrderBy><FieldRef Name="EndDate" Ascending="False"/></OrderBy>
   <Where>

但这做到了:

<![CDATA[<OrderBy><FieldRef Name="EndDate" Ascending="False"/></OrderBy><Where>

很奇怪,但再次感谢您发布这个答案,它节省了我很多时间。

THanks for this. Just to clarify, there should be no white spaces before or after the tags as well.

This did not work:

<![CDATA[
   <OrderBy><FieldRef Name="EndDate" Ascending="False"/></OrderBy>
   <Where>

But this did:

<![CDATA[<OrderBy><FieldRef Name="EndDate" Ascending="False"/></OrderBy><Where>

Wierd but thanks again for posting this answer, it saved me a lot of time.

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