12

I am facing a strange problem that is easy to reproduce with SharePoint 2013:

  1. Go to the MySite
  2. Add a search results webpart.
  3. Change the search result webpart to a static query
  4. Use the context search on the mysite on the top right

The search query updates the search webpart and does not redirect to the search center.

Any workarounds?

2

This is due to the search box web part automatically connecting to the search results as part of that webparts default behavior. Unfortunately from the search results web part you cannot disconnect this it seems. I have also tried unchecking the allow connections to try to disable this.

Ultimately it came down to JavaScript when I was trying to find an answer for this. I thought I could just use a Script Editor however those are not available for My Sites and even if you import from a regular site the webpart schema, the JS will not run.

Thus, editing the Master seems to be the only way to do this. Add the following JS near the bottom, perhaps just before body.

<script type="text/javascript">
Sys.Application.add_load(stopInplaceQuery);
function stopInplaceQuery(){
    var searchInputBox = $find('ctl00_PlaceHolderMain_searchInputBox_csr');
    if(searchInputBox != null && typeof searchInputBox != "undefined"){
        searchInputBox.set_tryInplaceQuery(false);
        console.log("Stopping inplace query");
    }
}
</script>

Note that my code is using a set_tryInplaceQuery which disables the request to try a local search results webpart. This is actually a property on the master control for that search box, however it seemed to not have any effect there:

<SEARCHWC:SearchBoxScriptWebPart runat="server" id="searchInputBox" DefaultDropdownNodeId="1001" ServerInitialRender="true" UseSharedSettings="true" ChromeType="none" EmitStyleReference="false" __WebPartId="{E4F08BB7-F5FD-453F-B9EF-E682D7403FAA}" TryInplaceQuery="false"  />

The JS code I provided may need testing, I am not sure how safe it in terms of executing at the right time. It may need some script on demand additions it you find that it works intermittently.

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.