Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm trying to create 3 different calendar views which I will use as overlays to represent the same set of data but color coded differently based on the calendar view shown.

Im using the object model to create the views as follows:

SPViewCollection allviews = list.Views;

string query = "bla bla ...";

view = allviews.Add("MyView", viewFields, query, 100, true, false, SPViewCollection.SPViewType.Calendar, false);

Now the problem I have is that when this view is created, the 'RecurrenceRowset' property is not set and the Calendar view shows empty.

If I change the viewtype as in:

view = allviews.Add("MyView", viewFields, query, 100, true, false, SPViewCollection.SPViewType.Recurrence, false);

The view displays all the items, however I need a calendar view. If I look at the default Calender view that is created in a calendar list the view xml clearly shows the recurrence property set to TRUE

<View Name="{F24E3A4A-67D8-4EEB-BB6A-6ABF7772DAB7}" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" Type="CALENDAR" TabularView="FALSE" RecurrenceRowset="TRUE" DisplayName="Calendar" Url="/sites/IC/Lists/Task Calendar/calendar.aspx" Level="1" />

In the object model however, if you create a view, the 'RecurrenceRowset' property is READ-ONLY. How do I set it???

share|improve this question
add comment

1 Answer

This answer is a bit of a hack but it should work. Change the flag via the webpart.

      using (var webPartManager = newView.ParentList.ParentWeb.GetLimitedWebPartManager(newView.Url, PersonalizationScope.Shared))
      {
        foreach (WebPart webPart in webPartManager.WebParts)
        {
          if (webPart is IListWebPart)
          {
            var listWebPart = (IListWebPart)webPart;
            if ((listWebPart.ViewFlags | SPViewFlags.RecurrenceRowset) != SPViewFlags.RecurrenceRowset)
            {
              listWebPart.ViewFlags = listWebPart.ViewFlags | SPViewFlags.RecurrenceRowset;
              webPartManager.SaveChanges(webPart);
            }
          }
        }
      }
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.