5

Me and my colleague are having a problem with disappearing programatically created (Calendar) list views.

After the creation of the site, the views are created correctly and are displayed in the view selector menu:

Views shown correctly

If u click on the view, its working correctly, but if u return to the previous page, all the calendar views are disappeared.

Views Gone

U can still select the views in the ribbon.

Views still in ribbon

Anyone has a solution? Thank you.

Edit: if i disable the view selector in the properties of the list view webpart and then back enable it, the views are back and shown correctly. But this doesn't solve the problem in code.

2 Answers 2

2

Using this code, the view stays in the view selector.

  • Calendar = name of the view that disappears
  • Events = name of the list where the view disappears

Code:

SPList listEvents = web.Lists["Events"];

foreach (SPView view in listEvents.Views)
{
     if (view.Title.Equals("Calendar"))
         continue;
     var pageUrl = web.Url + "/"  + view.Url;
     SPLimitedWebPartManager webpartmanager = web.GetLimitedWebPartManager(pageUrl, System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);

     XsltListViewWebPart wp = webpartmanager.WebParts[0] as XsltListViewWebPart;

     wp.ViewSelectorFetchAsync = false;
     webpartmanager.SaveChanges(wp);
}

Source: http://mypowershell.webnode.sk/news/calendar-view-is-missing-in-view-selector/

0

maybe something like this works:

<![CDATA[
      <webParts>
          <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
              <metaData>
                  <type name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart,Microsoft.SharePoint,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" />
              </metaData>
              <data>
                  <properties>
                      <property name="DisableViewSelectorMenu" type="bool">False</property>
                  </properties>
              </data>
          </webPart>
      </webParts>
  ]]>
1
  • Hi, thanks for your answer. but this doesn't seem to work for me. i Don't think i can't get to the properties like this.
    – DrZoidberg
    Commented Jan 27, 2014 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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