This project has moved and is read-only. For the latest updates, please go here.

Using AddView to create a new view for a calendar

Mar 12, 2014 at 6:00 PM
Edited Mar 14, 2014 at 12:41 PM
Is it possible to specify either an existing view to use as a template (preferred), or a specific view type when using AddView?

I'm trying to use it to create a new calendar view, and I've specified type as HTML (as it seems the only other option is Grid). My calendar's default view is of type "calendar" but the new view hasn't been created as the same type, but rather just a standard view with the selected columns and filtering.

Looking at the URLs when you do this manually via the calendar itself the querystring either includes &View=[view GUID] if you are creating a new view based on an existing one, or &Calendar=True&BaseViewID=2 if just creating a new view of type calendar.

Looking at the MSDN documentation it isn't clear if there is a way of encoding either of the two options above, although the only one that would really work for me is being able to base the added view on an existing view, as the view I want to copy from and add new filter options to includes a CEWP with calls to jQuery and SPServices scripts to perform additional formatting of the view.

I'm using SharePoint 2007.

Mar 15, 2014 at 9:55 PM
Further to my initial post, I have now discovered that simply being able to base a new view on an existing calendar view (however useful that may have been) wouldn't help in this situation. My new page not only has to include the calendar list view, but also additional CEWPs on the page that are used to call SPServices and custom jQuery and Javascript code. From the SharePoint UI even manually creating a new calendar view from my existing one doesn't work, as I get the calendar list view but not the CEWPs. The only way to achieve what I need is to do a file system copy using SharePoint Designer.
So, my revised question is (a) is there any way to copy a list view page to a new one as a file system copy (retaining the CEWPs), and (b) would EditView then allow me to change the query properties of the calendar list view on this new page so that I have a new filter applied.
I need my solution to work this way because I'm trying to show filtered events from a calendar that may eventually contain many thousands of events, and the CAML query ensures that recurring events are correctly shown (I'm on SP2007 and have problems using SPServices to handle such events properly) and it also ensures that I have my subset of events before the calendars cells on the page are created and so I'm not faced with large cells filled with lots of hidden events, which would happen if I used jQuery to simply hide the ones that didn't math my filter.

Any thoughts anyone?