7

I have the big question for you : How to provision a simple page with 2 ListView Webpart?

What i want :

I am provisioning a simple page (using OneColumns layout) via pnp and remote provsionsing. My XML template is quite simple : One page, 2 XsltListView WebParts.

These Webparts should list elements from the same list, but using different views and one JSLink. The WebParts have to disable any toolbar buttons. We don't have to see the toolbar

What i have :

My Page in XML Template :

<pnp:Page Url="{site}/SitePages/Cartesvisites.aspx" Layout="OneColumn" Overwrite="true">
          <pnp:WebParts>
            <pnp:WebPart Title="Client" Row="1" Column="1">
              <pnp:Contents>
                <webParts>
                  <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
                    <metaData>
                      <type name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart, Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
                      <importErrorMessage>Impossible d'importer ce composant WebPart.</importErrorMessage>
                    </metaData>
                    <data>
                      <properties>
                        <property name="ShowWithSampleData" type="bool">False</property>
                        <property name="Default" type="string" />
                        <property name="JSLink" type="string">~siteCollection/Style Library/ASI/js/contacts_JSLink.js</property>
                        <property name="CacheXslStorage" type="bool">True</property>
                        <property name="ViewContentTypeId" type="string" />
                        <property name="XmlDefinitionLink" type="string" />
                        <property name="ManualRefresh" type="bool">False</property>
                        <property name="ListUrl" type="string" null="true" />
                        <property name="ListId" type="System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">{listid:Contacts}</property>
                        <property name="TitleUrl" type="string">{site}/Lists/Contacts</property>
                        <property name="EnableOriginalValue" type="bool">False</property>
                        <property name="Direction" type="direction">NotSet</property>
                        <property name="ServerRender" type="bool">False</property>
                        <property name="ViewFlags" type="Microsoft.SharePoint.SPViewFlags, Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">Html, TabularView, Hidden</property>
                        <property name="AllowConnect" type="bool">True</property>
                        <property name="ListName" type="string">{{listid:Contacts}}</property>
                        <property name="ListDisplayName" type="string" null="true" />
                        <property name="AllowZoneChange" type="bool">True</property>
                        <property name="DisableSaveAsNewViewButton" type="bool">False</property>
                        <property name="ViewFlag" type="string" />
                        <property name="DataSourceID" type="string" />
                        <property name="ExportMode" type="exportmode">All</property>
                        <property name="AutoRefresh" type="bool">False</property>
                        <property name="FireInitialRow" type="bool">True</property>
                        <property name="AllowEdit" type="bool">True</property>
                        <property name="Description" type="string" />
                        <property name="HelpMode" type="helpmode">Modeless</property>
                        <property name="BaseXsltHashKey" type="string" null="true" />
                        <property name="AllowMinimize" type="bool">True</property>
                        <property name="CacheXslTimeOut" type="int">86400</property>
                        <property name="ChromeType" type="chrometype">TitleOnly</property>
                        <property name="Xsl" type="string" null="true" />
                        <property name="ChromeState" type="chromestate">Normal</property>
                        <property name="CatalogIconImageUrl" type="string">/_layouts/15/images/itgen.png?rev=44</property>
                        <property name="SampleData" type="string" null="true" />
                        <property name="UseSQLDataSourcePaging" type="bool">True</property>
                        <property name="TitleIconImageUrl" type="string" />
                        <property name="PageSize" type="int">-1</property>
                        <property name="ShowTimelineIfAvailable" type="bool">True</property>
                        <property name="Width" type="string" />
                        <property name="DataFields" type="string" />
                        <property name="Hidden" type="bool">False</property>
                        <property name="Title" type="string">Client</property>
                        <property name="PageType" type="Microsoft.SharePoint.PAGETYPE, Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">PAGE_NORMALVIEW</property>
                        <property name="DataSourcesString" type="string" />
                        <property name="AllowClose" type="bool">True</property>
                        <property name="InplaceSearchEnabled" type="bool">True</property>
                        <property name="WebId" type="System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">00000000-0000-0000-0000-000000000000</property>
                        <property name="Height" type="string" />
                        <property name="GhostedXslLink" type="string">main.xsl</property>
                        <property name="DisableViewSelectorMenu" type="bool">False</property>
                        <property name="DisplayName" type="string" />
                        <property name="IsClientRender" type="bool">False</property>
                        <property name="XmlDefinition" type="string">&lt;View Name="{4817539C-2F0A-4D7D-AB54-99ECE3B95DD7}" Type="HTML" Hidden="TRUE" DisplayName="" Url="{site}/SitePages/Accueil.aspx" Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/15/images/generic.png?rev=44" &gt;&lt;Query&gt;&lt;Where&gt;&lt;Neq&gt;&lt;FieldRef Name="Company"/&gt;&lt;Value Type="Text"&gt;ASI&lt;/Value&gt;&lt;/Neq&gt;&lt;/Where&gt;&lt;/Query&gt;&lt;ViewFields&gt;&lt;FieldRef Name="LinkTitle"/&gt;&lt;FieldRef Name="EMail"/&gt;&lt;FieldRef Name="Modified"/&gt;&lt;FieldRef Name="CellPhone"/&gt;&lt;FieldRef Name="FirstName"/&gt;&lt;FieldRef Name="roleprojet"/&gt;&lt;FieldRef Name="Company"/&gt;&lt;FieldRef Name="WorkPhone"/&gt;&lt;/ViewFields&gt;&lt;RowLimit Paged="TRUE"&gt;30&lt;/RowLimit&gt;&lt;JSLink&gt;clienttemplates.js&lt;/JSLink&gt;&lt;XslLink Default="TRUE"&gt;main.xsl&lt;/XslLink&gt;&lt;Toolbar Type="Standard"/&gt;&lt;/View&gt;</property>
                        <property name="InitialAsyncDataFetch" type="bool">False</property>
                        <property name="NoDefaultStyle" type="string" />
                        <property name="AllowHide" type="bool">True</property>
                        <property name="ParameterBindings" type="string">&lt;ParameterBinding Name="dvt_sortdir" Location="Postback;Connection" /&gt;&lt;ParameterBinding Name="dvt_sortfield" Location="Postback;Connection" /&gt;&lt;ParameterBinding Name="dvt_startposition" Location="Postback" DefaultValue="" /&gt;&lt;ParameterBinding Name="dvt_firstrow" Location="Postback;Connection" /&gt;&lt;ParameterBinding Name="OpenMenuKeyAccessible" Location="Resource(wss,OpenMenuKeyAccessible)" /&gt;&lt;ParameterBinding Name="open_menu" Location="Resource(wss,open_menu)" /&gt;&lt;ParameterBinding Name="select_deselect_all" Location="Resource(wss,select_deselect_all)" /&gt;&lt;ParameterBinding Name="idPresEnabled" Location="Resource(wss,idPresEnabled)" /&gt;&lt;ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" /&gt;&lt;ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_DEFAULT)" /&gt;</property>
                        <property name="DataSourceMode" type="Microsoft.SharePoint.WebControls.SPDataSourceMode, Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">List</property>
                        <property name="AutoRefreshInterval" type="int">60</property>
                        <property name="AsyncRefresh" type="bool">False</property>
                        <property name="HelpUrl" type="string" />
                        <property name="MissingAssembly" type="string">Impossible d'importer ce composant WebPart.</property>
                        <property name="XslLink" type="string" null="true" />
                        <property name="SelectParameters" type="string" />
                        <property name="HasClientDataSource" type="bool">False</property>
                      </properties>
                    </data>
                  </webPart>
                </webParts>
              </pnp:Contents>
            </pnp:WebPart>
            <pnp:WebPart Title="US" Row="1" Column="1">
              <pnp:Contents>
                <webParts>
                  <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
                    <metaData>
                      <type name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart, Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
                      <importErrorMessage>Impossible d'importer ce composant WebPart.</importErrorMessage>
                    </metaData>
                    <data>
                      <properties>
                        <property name="ShowWithSampleData" type="bool">False</property>
                        <property name="Default" type="string" />
                        <property name="JSLink" type="string" null="true" />
                        <property name="CacheXslStorage" type="bool">True</property>
                        <property name="ViewContentTypeId" type="string" />
                        <property name="XmlDefinitionLink" type="string" />
                        <property name="ManualRefresh" type="bool">False</property>
                        <property name="ListUrl" type="string" null="true" />
                        <property name="ListId" type="System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">{listid:Contacts}</property>
                        <property name="TitleUrl" type="string">{site}/Lists/Contacts</property>
                        <property name="EnableOriginalValue" type="bool">False</property>
                        <property name="Direction" type="direction">NotSet</property>
                        <property name="ServerRender" type="bool">False</property>
                        <property name="ViewFlags" type="Microsoft.SharePoint.SPViewFlags, Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">Html, TabularView, Hidden</property>
                        <property name="AllowConnect" type="bool">True</property>
                        <property name="ListName" type="string">{{listid:Contacts}}</property>
                        <property name="ListDisplayName" type="string" null="true" />
                        <property name="AllowZoneChange" type="bool">True</property>
                        <property name="DisableSaveAsNewViewButton" type="bool">False</property>
                        <property name="ViewFlag" type="string" />
                        <property name="DataSourceID" type="string" />
                        <property name="ExportMode" type="exportmode">All</property>
                        <property name="AutoRefresh" type="bool">False</property>
                        <property name="FireInitialRow" type="bool">True</property>
                        <property name="AllowEdit" type="bool">True</property>
                        <property name="Description" type="string" />
                        <property name="HelpMode" type="helpmode">Modeless</property>
                        <property name="BaseXsltHashKey" type="string" null="true" />
                        <property name="AllowMinimize" type="bool">True</property>
                        <property name="CacheXslTimeOut" type="int">86400</property>
                        <property name="ChromeType" type="chrometype">TitleOnly</property>
                        <property name="Xsl" type="string" null="true" />
                        <property name="ChromeState" type="chromestate">Normal</property>
                        <property name="CatalogIconImageUrl" type="string">/_layouts/15/images/itgen.png?rev=44</property>
                        <property name="SampleData" type="string" null="true" />
                        <property name="UseSQLDataSourcePaging" type="bool">True</property>
                        <property name="TitleIconImageUrl" type="string" />
                        <property name="PageSize" type="int">-1</property>
                        <property name="ShowTimelineIfAvailable" type="bool">True</property>
                        <property name="Width" type="string" />
                        <property name="DataFields" type="string" />
                        <property name="Hidden" type="bool">False</property>
                        <property name="Title" type="string">ASI</property>
                        <property name="PageType" type="Microsoft.SharePoint.PAGETYPE, Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">PAGE_NORMALVIEW</property>
                        <property name="DataSourcesString" type="string" />
                        <property name="AllowClose" type="bool">True</property>
                        <property name="InplaceSearchEnabled" type="bool">True</property>
                        <property name="WebId" type="System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">00000000-0000-0000-0000-000000000000</property>
                        <property name="Height" type="string" />
                        <property name="GhostedXslLink" type="string">main.xsl</property>
                        <property name="DisableViewSelectorMenu" type="bool">False</property>
                        <property name="DisplayName" type="string" />
                        <property name="IsClientRender" type="bool">False</property>
                        <property name="XmlDefinition" type="string">&lt;View Name="{31F5DC14-2185-4D42-861E-DDF5B1A29662}" Type="HTML" Hidden="TRUE" DisplayName="" Url="{site}/SitePages/Accueil.aspx" Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/15/images/generic.png?rev=44" &gt;&lt;Query&gt;&lt;Where&gt;&lt;Eq&gt;&lt;FieldRef Name="Company"/&gt;&lt;Value Type="Text"&gt;ASI&lt;/Value&gt;&lt;/Eq&gt;&lt;/Where&gt;&lt;/Query&gt;&lt;ViewFields&gt;&lt;FieldRef Name="LinkTitle"/&gt;&lt;FieldRef Name="EMail"/&gt;&lt;FieldRef Name="Modified"/&gt;&lt;FieldRef Name="CellPhone"/&gt;&lt;FieldRef Name="FirstName"/&gt;&lt;FieldRef Name="roleprojet"/&gt;&lt;FieldRef Name="Company"/&gt;&lt;FieldRef Name="WorkPhone"/&gt;&lt;/ViewFields&gt;&lt;RowLimit Paged="TRUE"&gt;30&lt;/RowLimit&gt;&lt;JSLink&gt;clienttemplates.js&lt;/JSLink&gt;&lt;XslLink Default="TRUE"&gt;main.xsl&lt;/XslLink&gt;&lt;Toolbar Type="Standard"/&gt;&lt;/View&gt;</property>
                        <property name="InitialAsyncDataFetch" type="bool">False</property>
                        <property name="NoDefaultStyle" type="string" />
                        <property name="AllowHide" type="bool">True</property>
                        <property name="ParameterBindings" type="string">&lt;ParameterBinding Name="dvt_sortdir" Location="Postback;Connection" /&gt;&lt;ParameterBinding Name="dvt_sortfield" Location="Postback;Connection" /&gt;&lt;ParameterBinding Name="dvt_startposition" Location="Postback" DefaultValue="" /&gt;&lt;ParameterBinding Name="dvt_firstrow" Location="Postback;Connection" /&gt;&lt;ParameterBinding Name="OpenMenuKeyAccessible" Location="Resource(wss,OpenMenuKeyAccessible)" /&gt;&lt;ParameterBinding Name="open_menu" Location="Resource(wss,open_menu)" /&gt;&lt;ParameterBinding Name="select_deselect_all" Location="Resource(wss,select_deselect_all)" /&gt;&lt;ParameterBinding Name="idPresEnabled" Location="Resource(wss,idPresEnabled)" /&gt;&lt;ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" /&gt;&lt;ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_DEFAULT)" /&gt;</property>
                        <property name="DataSourceMode" type="Microsoft.SharePoint.WebControls.SPDataSourceMode, Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">List</property>
                        <property name="AutoRefreshInterval" type="int">60</property>
                        <property name="AsyncRefresh" type="bool">False</property>
                        <property name="HelpUrl" type="string" />
                        <property name="MissingAssembly" type="string">Impossible d'importer ce composant WebPart.</property>
                        <property name="XslLink" type="string" null="true" />
                        <property name="SelectParameters" type="string" />
                        <property name="HasClientDataSource" type="bool">False</property>
                      </properties>
                    </data>
                  </webPart>
                </webParts>
              </pnp:Contents>
            </pnp:WebPart>

          </pnp:WebParts>
        </pnp:Page>

What are the problems :

The result is : My page and Webparts are created, but my Webparts have 2 problems :

1.The toolBar is shown. And i don't want it to be displayed.

  1. The JSLink is not applied. I found why, but i did not found the solution. Here is why : As you can see in the XML, the JSLink is wrote the same way it should in a webpart : using "~siteCollection" to reference site collection. But, when the webpart is provisioned in the page, the "~siteCollection" is interpreted and replaced by my actual site collection in the WP's settings. So in the WP settings, it should be wrote "~siteCollection/Style Library/MyJSLink.js" but the provisioning wrote it like this : "mySiteCollection/Style Library/MyJSLink.js", which is not understood by SP.

So please, could you help me to:

  1. How to specify in the XML template that i don't want any tool bar in my webparts.
  2. How to escape/encode the special "~siteCollection" in the xml content, so it is not interpreted and is wrote in the WP settings as it is written in the xml template.

----/ EDIT : I FOUND THE SOLUTION FOR THE 2ND PROBLEM ----

I found the solution for escaping the ~siteCollection, finally it was simple : Instead of the "~", we have to write the tilde with the HTML code : &#126; Like this : &#126;SiteCollection/Style Library/MyJSLink.js

----/ EDIT END ------

Thanks a lot fellows, have a nice day !

  • It seems that #1 is not possible. I've also spent a lot of time trying to achieve this. I ended up hiding the toolbar with JSLink as described here: n8d.at/blog/… – milosz Jul 20 '17 at 7:33
1

For #1 - in the past I've tried different approaches without success.

Finally as workaround I had to put script editor web part to the page with link to stylescheet and hided toolbar with css...

Good to know you resolved your #2 issue!

  • Well, I talked too fast, finally my solution for #2 is not taken into account... And some aggregation in other views are not well too... (sigh) Thanks for your idea about the workaround, i'll see if we launch it in prod. – Gaelle Dec 1 '16 at 16:57
  • So do you solution for #2 work? Or is PnP still replaces &#126;SiteCollection? In that case I would say this is a bug... What is the problem with aggregations? – Sergei Sergeev Dec 2 '16 at 6:05
  • @Gaelle: any news here? :) – Sergei Sergeev Dec 6 '16 at 14:38
  • Hello @Kai : unfortunately no news. I am focusing and traying excessively hard to have a page showing the right views without any added button. So for now the jslink is at the todo list's bottom... – Gaelle Dec 6 '16 at 14:42
  • Hello @Kai ! so, i've tried it again, and yup, &#126;SiteCollection (and &#126;siteCollection as well) is replaced by litterally my site collection, instead of ~sitecollection . So finally my resolution was not good (even if at one point, i don't know how, it worked). And for aggregation it is not taken in account by the core yet. – Gaelle Jan 5 '17 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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