If you configure SharePoint 2013 to work with Office Web Apps (link), by default SharePoint will open Word, Excel etc. documents in the browser using the Office Web Apps. You can configure SharePoint to open documents in the client application or browser on a site collection or document library basis, see here. However, even if you choose to configure SharePoint to open documents in the client application at the site collection, search results still open in the browser. In my case I wanted Office Web App integration to enable search result previews, but I wanted search results to open in the client application.
In order to open search results in the client application I had to alter the Item_CommonItem_Body.html search results display template. Item_CommonItem_Body.html is the display template that’s rendered by _#=ctx.RenderBody(ctx)=#_ within a display template. Below is the section in one of my custom display templates.
For an overview of display templates read this MS Technet blog article.
Within Item_CommonItem_Body.html is a section that references ctx.ScriptApplicationManager.states.openDocumentsInClient.
In order to force search results to open in the client application I added a line in my custom display template to set the value of ctx.ScriptApplicationManager.states.openDocumentsInClient to true.
This results in the behavior where search result previews using Office Web Apps still work, but when a user clicks on a result it opens in the client application.
Hi,
thank you for the solution.
At the Moment I have the problem that the first search result in the list still have the deaultOpenItem=1 extension and it open in the browser. The other results in the list works fine.
Do you have an idea why?
regards
Dominik
Check that a different display template isn’t being used to render the search result.
I had this issue too but I was able to fix it by moving the suggested line of code to be the first line in the script tag.
Where do i have to move the code? so in the search documents are opened in Client?
I’ve added an extra screenshot to show the position of the code within my example template. I hope this helps.
at the bottom of the page. there is one setting as preference .. you can change that behavior of opening document.
cool this helped me!