Connect WebParts declaratively in a Module elements.xml

Hi,

Since it took me so long to make this work, and given that I couldn't really find very useful information on the web, I'll ask this and answer it myself :D

In case anyone needs it!


Amadeo

June 22nd, 2011 4:59pm

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="Module1">
    <File Path="Module1\Test.aspx" Url="Module1/Test.aspx">
      <AllUsersWebPart ID="provider" WebPartZoneID="Left" WebPartOrder="0">
        <![CDATA[<webParts>
  <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
    <metaData>
      <type name="Microsoft.SharePoint.Portal.WebControls.QueryStringFilterWebPart, Microsoft.Office.Server.FilterControls, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
      <importErrorMessage>Cannot import this web part.</importErrorMessage>
    </metaData>
    <data>
      <properties>
        <property name="FilterName" type="string">FilterWebPart</property>
        <property name="SendEmptyWhenNoValues" type="bool">False</property>
        <property name="HelpUrl" type="string" />
        <property name="AllowClose" type="bool">True</property>
        <property name="ExportMode" type="exportmode">All</property>
        <property name="AllowMinimize" type="bool">True</property>
        <property name="DefaultValue" type="string" />
        <property name="AllowEdit" type="bool">True</property>
        <property name="Direction" type="direction">NotSet</property>
        <property name="TitleIconImageUrl" type="string">/_layouts/images/wp_Filter.gif</property>
        <property name="AllowConnect" type="bool">True</property>
        <property name="MissingAssembly" type="string">Cannot import this web part.</property>
        <property name="AllowHide" type="bool">True</property>
        <property name="Description" type="string">Filters the contents of Web Parts using values passed via the query string.</property>
        <property name="Hidden" type="bool">False</property>
        <property name="CatalogIconImageUrl" type="string">/_layouts/images/wp_Filter.gif</property>
        <property name="MultipleValueHandling" type="Microsoft.SharePoint.Portal.WebControls.FilterMultipleValueHandling, Microsoft.Office.Server.FilterControls, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">SendFirst</property>
        <property name="HelpMode" type="helpmode">Modeless</property>
        <property name="ValueSeparator" type="string" />
        <property name="AllowZoneChange" type="bool">True</property>
        <property name="Height" type="string" />
        <property name="QueryStringParameterName" type="string">Title</property>
        <property name="ChromeType" type="chrometype">None</property>
        <property name="Width" type="string" />
        <property name="Title" type="string">Query String (URL) Filter</property>
        <property name="ChromeState" type="chromestate">Normal</property>
        <property name="TitleUrl" type="string" />
      </properties>
    </data>
  </webPart>
</webParts>]]>
      </AllUsersWebPart>
      <AllUsersWebPart ID="consumer" WebPartZoneID="Left" WebPartOrder="2">
        <![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>$Resources:core,ImportErrorMessage;</importErrorMessage>
            </metaData>
            <data>
              <properties>
                <property name="Title" type="string">MyListWebPart</property>
                <property name="Description" type="string">My WebPart</property>
                <property name="ListUrl" type="string">Lists/MyList</property>
                <property name="BaseViewID" type="int">1</property>
              </properties>
            </data>
          </webPart>
        </webParts>]]>
      </AllUsersWebPart>
      <AllUsersWebPart ID="consumer2" WebPartZoneID="Left" WebPartOrder="2">
        <![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>$Resources:core,ImportErrorMessage;</importErrorMessage>
            </metaData>
            <data>
              <properties>
                <property name="Title" type="string">MyList2WebPart</property>
                <property name="Description" type="string">My WebPart</property>
                <property name="ListUrl" type="string">Lists/MyList2</property>
                <property name="BaseViewID" type="int">1</property>
              </properties>
            </data>
          </webPart>
        </webParts>]]>
      </AllUsersWebPart>
      <WebPartConnection ID="connection" ProviderID="provider" ProviderConnectionPointID="ITransformableFilterValues"	ConsumerID="consumer" ConsumerConnectionPointID="DFWP Filter Consumer ID">
        <WebPartTransformer Assembly="Microsoft.SharePoint,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" Namespace="Microsoft.SharePoint.WebPartPages">
          <![CDATA[<WebPartPages:TransformableFilterValuesToParametersTransformer ConsumerFieldNames="Title" ProviderFieldNames="FilterWebPart" />]]>
        </WebPartTransformer>
      </WebPartConnection>
      <WebPartConnection ID="connection2" ProviderID="provider" ProviderConnectionPointID="ITransformableFilterValues"	ConsumerID="consumer2" ConsumerConnectionPointID="DFWP Filter Consumer ID">
        <WebPartTransformer Assembly="Microsoft.SharePoint,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" Namespace="Microsoft.SharePoint.WebPartPages">
          <![CDATA[<WebPartPages:TransformableFilterValuesToParametersTransformer ConsumerFieldNames="Title" ProviderFieldNames="FilterWebPart" />]]>
        </WebPartTransformer>
      </WebPartConnection>
    </File>
  </Module>
</Elements>
Free Windows Admin Tool Kit Click here and download it now
June 22nd, 2011 5:01pm

Then please post it to a blog, not as a forum post.
June 23rd, 2011 6:28am

Hello,

Weirdly, this doesn't work for me. I have setup the connection in declarative xml and when the page is created, in Edit mode it LOOKS like the web parts are connected, based on what I see in the 'connect' menus. But the Provider web part does not send data to the consumer. It only starts sending data when I click on the provisioned connection in Edit mode of the page (which opens the connection popup) and then I click the 'Finish' button. Any clue?

			<!-- Connect the Path Provider to the Consumer -->
			<WebPartConnection ID="connectionId"
												 ProviderID="WPPathProvider"
												 ProviderConnectionPointID="DFWP Row Provider ID"
												 ConsumerID="WPPathConsumer"
												 ConsumerConnectionPointID="DFWP Parameter Consumer ID">
				<WebPartTransformer Assembly="Microsoft.SharePoint,Version=15.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" Namespace="Microsoft.SharePoint.WebPartPages">
					<![CDATA[<WebPartPages:TransformableFilterValuesToParametersTransformer ConsumerFieldNames="ParamRootFolder" ProviderFieldNames="LinkFilename" />]]>
				</WebPartTransformer>
			</WebPartConnection>



Free Windows Admin Tool Kit Click here and download it now
May 16th, 2015 5:17am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics