1

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

  1. 我的站点定义中有一个具有多个视图的自定义列表实例...
  2. 我有一个页面,我想显示其中一个视图...
  3. 在页面的 Elements.xml 定义中,我可以在哪里选择显示下面列表实例的 Schema.xml 中显示的“通信”或“会计”视图?

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>
4

1 回答 1

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并给出 的唯一 ID BaseViewID

比你的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/

于 2013-03-28T06:39:35.660 回答