I’m using a calendar to track panel discussions on a given day. I have two sessions: morning and afternoon. I want to create a view that shows morning sessions only listed alphabetically via a session ID. This is a little tricky to accomplish (unless I missed something real obvious).
I can easily create a filtered view showing just that day’s events. The calendar will show all those events and if they all take place on the same hour, it lists them side by side in the hour slot. That’s great. The tricky part is that, by default, it wants to list them in ID format. So, if I add "Session 02" and then "Session 01" to the calendar, it shows them in that order (i.e, Session 02 and then Session 01). To list them in Session ID order, I thought to try these things:
- Configure the view using the web user interface. No luck. There are no options to sort items this way.
Since that didn’t work, I am now hoping there’s a CAML query somewhere in there that will allow me to override the sort. CQWP lets me make that kind of change, maybe calendar will as well?
- Edit the web part, look for an "export" function and … BZZZT! I can’t export its XML. There is no export option.
I’m still holding out hope that I can find and modify some CAML query. Since I can’t export the web part, that leaves SharePoint Designer.
- I add the calendar web part to a sandbox site and open that site using SharePoint Designer. I look at the markup for the web part and I find what I’m looking for. It’s encoded madness, but it’s there: "<ListViewXml …. >encoded madness</ListViewXml>". Specifically, there’s this gem:
<Query>
<Where>
<DateRangesOverlap>
<FieldRef Name="EventDate"/>
<FieldRef Name="EndDate"/>
<FieldRef Name="RecurrenceID"/>
<Value Type="DateTime">
<Month/>
</Value>
</DateRangesOverlap>
</Where>
<OrderBy><FieldRef Name="Session_x0020_ID" /></OrderBy>
</Query>
(I’ve decoded the <’s and >’s and split them out to multiple lines for clarity’s sake).
Add the <OrderBy> bit and now it sorts by Session ID, not the internal list item ID.
GIGANTIC tip o’ the hat to Becky Isserman for her comment to Isha Sagi’s blog post: http://www.sharepoint-tips.com/2008/07/caml-sorting-by-file-name.html. I wouldn’t have put the <OrderBy> in the right place without her comment.
I hope to write this up more clearly with screen shots soon, but in case I never do, at least I did this much.
</end>