将文档库Web部件添加到网站定义中的页面时,如何选择哪个视图?

时间:2013-03-28 01:18:38

标签: sharepoint sharepoint-2010 document-library sharepointdocumentlibrary site-definition

在我的自定义SharePoint 2010网站定义中:

  1. 我的网站定义中有一个包含多个视图的自定义列表实例...
  2. 我有一个页面,我想在...上显示其中一个视图。
  3. 在页面的Elements.xml定义中,我可以在哪里选择显示下面列表实例的Schema.xml中显示的“Correspondence”或“Accounting”视图?
  4. 为了简化阅读,已经清理了XML。

    列出实例的Schema.xml

    <List Title="Client Documents" Direction="none" Url="Client Documents" BaseType="1" Type="101" BrowserFileHandling="Permissive" EnableContentTypes="TRUE" DisableAttachments="TRUE" Catalog="FALSE" VersioningEnabled="TRUE" SendToLocation="|" ImageUrl="/_layouts/images/itdl.png" xmlns:ows="Microsoft SharePoint" xmlns:spctf="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms" xmlns="http://schemas.microsoft.com/sharepoint/">
      <MetaData>
        <ContentTypes>...</ContentTypes>
        <Fields>...</Fields>
        <Forms />
        <Views>
          ...
          <View DisplayName="CORE Client - Accounting" BaseViewID="1" Type="HTML" MobileView="TRUE" ImageUrl="/_layouts/images/dlicon.png" XslLink="main.xsl" WebPartZoneID="Main" WebPartOrder="1" Url="Forms/CORE Client  Accounting.aspx" SetupPath="pages\viewpage.aspx">
            <XslLink>main.xsl</XslLink>
            <Query>
              <Where>
                <Eq>
                  <FieldRef Name="ContentType" />
                  <Value Type="Computed">Client - Accounting</Value>
                </Eq>
              </Where>
            </Query>
            <ViewFields>...</ViewFields>
            <RowLimit Paged="TRUE">30</RowLimit>
            <Aggregations Value="Off" />
          </View>
          <View DisplayName="CORE Client - Correspondence" BaseViewID="1" Type="HTML" MobileView="TRUE" ImageUrl="/_layouts/images/dlicon.png" XslLink="main.xsl" WebPartZoneID="Main" WebPartOrder="1" Url="Forms/CORE Client  Correspondence.aspx" SetupPath="pages\viewpage.aspx">
            <XslLink>main.xsl</XslLink>
            <Query>
              <GroupBy Collapse="TRUE" GroupLimit="30">
                <FieldRef Name="Client_x0020_Correspondence_x0020_Type" />
              </GroupBy>
              <Where>
                <Eq>
                  <FieldRef Name="ContentType" />
                  <Value Type="Computed">Client - Correspondence</Value>
                </Eq>
              </Where>
            </Query>
            <ViewFields>...</ViewFields>
            <RowLimit Paged="TRUE">30</RowLimit>
            <Aggregations Value="Off" />
          </View>
          ...
        </Views>
      </MetaData>
    </List>
    

    模块的Elements.xml

    <File Url="ClientDocumentsCorrespondence.aspx" Path="default.aspx" Type="GhostableInLibrary" >
        <Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/PLClientDocuments.aspx" />
        <Property Name="Title" Value="GASOP Client Documents - Correspondence" />
        <Property Name="ContentType" Value="Welcome Page" />
        <AllUsersWebPart WebPartOrder="0" WebPartZoneID="zone1">...</AllUsersWebPart>
        <AllUsersWebPart WebPartOrder="1" WebPartZoneID="zone1">...</AllUsersWebPart>
        <View List="Client Documents"
            DisplayName=""
            Url=""
            DefaultView="FALSE"
            BaseViewID="1"
            Type="HTML"
            WebPartOrder="0"
            WebPartZoneID="zone2"
            ContentTypeID="0x"
            ID="g_4d8c86ec_b324_4f6a_a2e9_ba1a36466c68"
            Hidden="TRUE">
        <![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>...</properties>
                </data>
            </webPart>
        </webParts>]]>
        </View>
    </File>
    

1 个答案:

答案 0 :(得分:1)

它似乎在schema.xml上创建了两个视图,但它们都具有相同的BaseViewID。每个视图必须是唯一的BaseViewID。 1是AllItems视图的ID(默认视图)。

请参阅此帖:http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/52e45ddd-73a8-400f-890c-323a0eaaeccb

复制粘贴default view并获得BaseViewID的唯一ID。

而不是Module's Elements.xml

  <View List="Lists/Client Documents" BaseViewID="<<Your View Unique ID>>"  DisplayName="Client Documents" Name="Client Documents" RecurrenceRowset="TRUE" WebPartZoneID="Main" WebPartOrder="0">
      <![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">Invoice Approved</property>
                          <property name="AllowConnect" type="bool">True</property>
                          <property name="AllowClose" type="bool">False</property>
                      </properties>
                  </data>
              </webPart>
          </webParts>
      ]]>
    </View>

请阅读更多详情:http://blog.qumsieh.ca/2010/09/01/sharepoint-2010-schema-xml-onet-xml-and-toolbar-type/