1

i couldn't get the InplaceSearch displayed on my webpart through onet.xml.

in my onet.xml file:

<View List="Lists/Aufgaben" BaseViewID="1" WebPartZoneID="TaskTab">
      <![CDATA[
        <webParts> 
            <webPart xmlns="http://schemas.microsoft.com/WebPart/v3"> 
                <metaData> 
                    <type name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" /> 
                    <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
                </metaData> 
                <data> 
                    <properties>
                      <property name="Title" type="string">Aufgaben</property>
                      <property name="ChromeType">None</property>
                      <property name="InplaceSearchEnabled">True</property>
                    </properties> 
                </data> 
            </webPart> 
        </webParts>   
        ]]>
    </View>

If I go on the page which is created with this onet.xml, there is the webpart shown but without the Inplace Search.

But... if I double check with PowerShell InplaceSearchEnabled property is correctly set to "True".

But... if I dribble check the WebPart properties on the page (over edit page...) the checkbox for InplaceSearch is not checked.

All other properties work fine (like Title and ChromeType). Why the InplaceSearch don't :(

  • I have tried to set the property both from elements.xml and from web part page by directly adding the XsltListViewWebPart. But, except InPlaceSearchEnabled property everything else working.... So, seems like they forgot to add the support to provision this property. But, If I set from browser it works. – Rare Solutions Apr 10 '15 at 4:43
  • 1
    Have you found a workaround? I encountered the same issue :( – Dmitry Kozlov Sep 9 '15 at 13:03
  • Also wondering if you have found a solution for this. Having the same issue. – Shihan Apr 21 '16 at 14:29
  • Try to add the viewid and clientrender = true property in <view... Check the right syntax from google... At the moment, I only have access via mobile phone... Let me know, if this fixed the problem... I think, I fixed this with this props... But I'm not really sure :) – domsen123 Apr 23 '16 at 17:09
0

I experienced the same issue and was able to solve it (actually, it's a workaround) with JavaScript. It won't set the flag itself to true but will 'emulate' it. Here is a copy-paste-able code. If you want some explanations, please use the link InplaceSearchEnabled doesn't work when set programmatically in XsltListViewWebPart

/// we need to wait until clienttemplates.js is loaded
SP.SOD.executeFunc('clienttemplates.js', 'SPClientTemplates', function () {
    // code that will be run before rendering the script. It'a good time to configure everything for search input
    function onPreRender(ctx) {
        if (!window.g_listSearchBoxInfo)
            window.g_listSearchBoxInfo = [];
        var hasSearch = false;
        // if the searci is configured for this web part we won't want to add it twice
        for (var i = 0, len = window.g_listSearchBoxInfo.length; i &lt; len; i++) {
            if (window.g_listSearchBoxInfo[i].wpq === ctx.wpq) {
                hasSearch = true;
                break;
            }
        }

        if (!hasSearch) {
            // the structure of the object was got during debugging session
            window.g_listSearchBoxInfo.push({
                fullSearchSiteUrl: _spPageContextInfo.webAbsoluteUrl,
                loadInProgress: false,
                searchBoxConstructor: null,
                sodFunc: null,
                sodKey: null,
                wpq: ctx.wpq
            });

            // setting InplaceSearchEnabled in ListSchema
            ctx.ListSchema.InplaceSearchEnabled = true;
        }
     }

    // registering CSR template override
    var overrideCtx = {};
    overrideCtx.OnPreRender = onPreRender;

    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(overrideCtx);

    // adding scripts (with condition if there were previously added or not)
    var searchScript = jQuery('script[src*="listsearchboxbootstrap.js"]');
    if (!searchScript.length) {
        RegisterSod('clientrenderer.js', '/_layouts/15/clientrenderer.js');
        RegisterSod('srch.resources.resx', '/_layouts/15/ScriptResx.ashx?culture=en-us&amp;name=Srch.Resources');
        RegisterSod('search.clientcontrols.js', '/_layouts/15/search.clientcontrols.js')
        RegisterSodDep('search.clientcontrols.js', 'clientrenderer.js');
        RegisterSodDep('search.clientcontrols.js', 'srch.resources.resx');
        RegisterSod('profilebrowserscriptres.resx', '/_layouts/15/ScriptResx.ashx?culture=en-us&amp;name=ProfileBrowserScriptRes');
        RegisterSod('sp.ui.listsearchbox.js', '/_layouts/15/sp.ui.listsearchbox.js');
        RegisterSodDep('sp.ui.listsearchbox.js', 'search.clientcontrols.js');
        RegisterSodDep('sp.ui.listsearchbox.js', 'profilebrowserscriptres.resx');

        var script = document.createElement('script');
        script.type = 'text/javascript';
        script.src = '/_layouts/15/sp.ui.listsearchboxbootstrap.js';
        document.head.appendChild(script);
    }
});
| improve this answer | |
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review – Aakash Maurya Jul 13 '16 at 4:45
  • updated to provide to code with some comments – AJIXuMuK Jul 14 '16 at 4:20

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.