Question

I am devloping a SP2013 App which includes a page (aspx) that contains the following webpart and XsltListViewWebPart as shown below. I have managed to remove all the elements i want to remove (Toolbar, seaarchbox etc) but I want to specify the view (I have created 4 views for the list) that the list default to but I can see any option to do this?

Anyone achived this?

<WebPartPages:WebPartZone runat="server" FrameType="None" ID="HolidayBalance" Title="loc:HolidayBalance" PartChromeType="TitleOnly" ShowTitleIcons="True" AllowLayoutChange="False">
        <WebPartPages:XsltListViewWebPart ID="XsltListYourHolidayBalance" runat="server" ListUrl="Lists/Personnel Holiday Entitlement"  IsIncluded="True" NoDefaultStyle="TRUE" Title="Your Holiday Balance" PageType="PAGE_NORMALVIEW" Default="True" DisableViewSelectorMenu="True" InplaceSearchEnabled="False" ShowToolbarWithRibbon="False" >

Was it helpful?

Solution

If you plan to provision the page using a Module, I'd recommend configuring the web part inside of the Module, rather than in the aspx file itself. This will allow you to select whichever view you would want:

<File Path="mypage.aspx" Url="mypage.aspx" Type="GhostableInLibrary">
  <View List="Lists/Personnel Holiday Entitlement" BaseViewID="4" WebPartZoneID="HolidayBalance" WebPartOrder="1">
    <![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" />
                      <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
                  </metaData>
                  <data>
                      <properties>
                          <property name="Title" type="string">Your Holiday Balance</property>
                          <property name="DisableViewSelectorMenu" type="bool">True</property>
                          <property name="InplaceSearchEnabled" type="bool">False</property>
                          <property name="ShowToolbarWithRibbon" type="bool">False</property>
                      </properties>
                  </data>
              </webPart>
          </webParts>
      ]]>
  </View>
</File>

Note: this example is from SP 2010, hopefully it's applicable and compatible with SP 2013.

OTHER TIPS

If you want to change it pro-grammatically check this link out. Where they getting the webpart and then setting it's view.

create or get XsltListViewWebPart

You can change default view in the definition of your list too.

Here's a similar question on SE that explains how to change list's default view in Schema.xml

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top