Content Query Web Part - How do you OrderBy when you 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
prope开发者_如何学Pythonrty of the Content Query Web Part?
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:
<![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.
精彩评论