内容查询 Web 部件 - QueryOverride 时如何 OrderBy?
当您重写内容查询 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的 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
谢谢你。需要澄清的是,标签之前或之后也不应该有空格。
这不起作用:
但这做到了:
很奇怪,但再次感谢您发布这个答案,它节省了我很多时间。
THanks for this. Just to clarify, there should be no white spaces before or after the tags as well.
This did not work:
But this did:
Wierd but thanks again for posting this answer, it saved me a lot of time.