15

I have a problem with the toolbar type "standard" in SharePoint 2013.

If I insert a XsltListViewWebPart with , there is no "New Element" button. And no "View Choice" and something like that. I've tested it with "Freeform" -> So only the old "New Element" on the bottom of the list appears. :(

Did someone have a solution for this?

My Code:

 <WebPartPages:XsltListViewWebPart runat="server" Title="Kundendokumente" ListDisplayName="Kundendokumente" DisplayName="Alle Dokumente" ChromeType="TitleOnly" FrameType="TitleBarOnly">
               <XmlDefinition>
                   <View Name="Alle Dokumente" TabularView="FALSE" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" Type="HTML" DisplayName="Alle Dokumente" Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/15/images/generic.png?rev=23" >
                       <ViewFields>
                            <FieldRef Name="DocIcon"/>
                            <FieldRef Name="LinkFilename" />
                            <FieldRef Name="Author" />
                            <FieldRef Name="Modified" />
                        </ViewFields>
                       <Toolbar Type="Freeform" />
                       <XslLink Default="TRUE">main.xsl</XslLink>
                       <RowLimit Paged="TRUE">30</RowLimit>
                       <JSLink>clienttemplates.js</JSLink>
                       <ParameterBindings>
                          <ParameterBinding Name="AddNewAnnouncement" Location="Resource(wss,addnewitem)" />
                          <ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" />
                          <ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_ONET_HOME)" />
                        </ParameterBindings>
                   </View>
               </XmlDefinition>
            </WebPartPages:XsltListViewWebPart>
1
  • Can you upload some image about the problem?
    – newbie
    Commented Dec 20, 2016 at 14:23

3 Answers 3

0

Here are list of properties that apply for XSLTListViewWebPart

<WebPartPages:XsltListViewWebPart runat="server" ViewFlag="" ViewSelectorFetchAsync="False" InplaceSearchEnabled="False" ServerRender="False" ClientRender="True" InitialAsyncDataFetch="False" WebId="00000000-0000-0000-0000-000000000000" IsClientRender="False" GhostedXslLink="main.xsl" NoDefaultStyle="" ViewGuid="{EA110B37-1CE7-4800-A8E0-49D05DB73C25}" EnableOriginalValue="False" ViewContentTypeId="" ListUrl="" ListDisplayName="" ListName="{2B48A275-6F41-422B-B048-803D107A87EF}" ListId="2b48a275-6f41-422b-b048-803d107a87ef" PageSize="-1" UseSQLDataSourcePaging="True" DataSourceID="" ShowWithSampleData="False" AsyncRefresh="False" ManualRefresh="False" AutoRefresh="False" AutoRefreshInterval="60" Title="Visitor" FrameType="Default" SuppressWebPartChrome="False" Description="" IsIncluded="True" ZoneID="g_E90068262CFD4E76AEDBEA6473F5DE20" PartOrder="2" FrameState="Normal" AllowRemove="True" AllowZoneChange="True" AllowMinimize="True" AllowConnect="True" AllowEdit="True" AllowHide="True" IsVisible="True" CatalogIconImageUrl="/_layouts/15/images/itgen.png?rev=40" TitleUrl="/Lists/Test" DetailLink="/Lists/Test" HelpLink="" HelpMode="Modeless" Dir="Default" PartImageSmall="" MissingAssembly="Cannot import this Web Part." PartImageLarge="/_layouts/15/images/itgen.png?rev=40" IsIncludedFilter="" ExportControlledProperties="False" ConnectionID="00000000-0000-0000-0000-000000000000" ID="g_ea110b37_1ce7_4800_a8e0_49d05db73c25" __MarkupType="vsattributemarkup" __WebPartId="{EA110B37-1CE7-4800-A8E0-49D05DB73C25}" __AllowXSLTEditing="true" __designer:CustomXsl="fldtypes_Ratings.xsl" WebPart="true" Height="" Width="">

The main elements is to make render at client side.

0

In order to see the toolbar, you need following three tags in the view definition:

<Toolbar Type="Standard" />
<XslLink Default="TRUE">main.xsl</XslLink>
<JSLink>clienttemplates.js</JSLink>

and to have ClientRender property of the web part set to "True". SharePoint will render the hero button, the search box and the view selection list on the top of the view.

0

I have only sucessfully updated the Toolbar with reflection. lvwp is your ListViewWebPart in the code below.

try
  {
    MethodInfo ensureViewMethod = lvwp.GetType().GetMethod("EnsureView", BindingFlags.Instance | BindingFlags.NonPublic);
    object[] ensureViewParams = { };
    ensureViewMethod.Invoke(lvwp, ensureViewParams);
    FieldInfo viewFieldInfo = lvwp.GetType().GetField("view", BindingFlags.NonPublic | BindingFlags.Instance);
    SPView view = viewFieldInfo.GetValue(lvwp) as SPView;
    Type[] toolbarMethodParamTypes = { Type.GetType("System.String") };
    MethodInfo setToolbarTypeMethod = view.GetType().GetMethod("SetToolbarType", BindingFlags.Instance | BindingFlags.NonPublic, null, toolbarMethodParamTypes, null);
    object[] setToolbarParam = { "None" }; //set the type here
    setToolbarTypeMethod.Invoke(view, setToolbarParam);
    view.Update();
  }
  catch { }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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