locked
Search Limit Override snippet causing issue with the OOB search webpart RRS feed

  • Question

  • Hello,

    We have used a JavaScript snippet which override the search limit i.e. from 49 to 500items in Content Search WebPart.

    <script type="text/javascript">
    //For this to work the web part must be set to render Async Client Side in the browser in the web part settings
    var $ocreate = null,maxItems = 500;
    
    // on application initialization steal the global create variable and intercept calls to create UI widgets.
    Sys.Application.add_init(function() {
       $ocreate = $create;
       $create = updateResultCountCreate;
    });
    // listen to UI widget calls for CBS & DP
    function updateResultCountCreate(a,b){
       var ps = Array.prototype.slice.call(arguments, 0);  
       if(a == Srch.ContentBySearch) b.numberOfItems = maxItems;
       if(a == Srch.DataProvider) b.resultsPerPage = maxItems;
       $ocreate.apply(this,ps);  // apply the original $create method that we stole
    }
    
    </script>

    I have followed this blog OverrideSearchLimit.

    Now this is creating an issue as the OOB search Webpart dropdown is not working because it calling the above search override snippet rather than OOB function.

     


    Please let me know if anyone has earlier faced this issue or how to resolve this issue.

    Any pointers would be really helpful.


    &quot;The Only Way To Get Smarter Is By Playing A Smarter Opponent&quot;

    Monday, February 8, 2016 4:59 AM

Answers

  • Hi Ravi,

    It might not be a good idea to override the built in script without making a fully understanding about how it works in the whole solution(in this case it is the OOTB Search feature), there would be a risk that users might come across with some unexpected behaviors when they use the OOTB feature in the ordinary way.

    Actually, I don’t think it is good for customers to get so many results in one page when there is already paging buttons for showing more data dynamically(ease the pressure on the browser), bad for performance and the user experience.

    If it is required to display mass search results in one page, it is recommended to develop a custom solution instead of altering the built in files, SharePoint has already exposed Search related APIs for developers:

    https://msdn.microsoft.com/en-us/library/office/dn423226.aspx 

    Best regards,

    Patrick

    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact tnmff@microsoft.com.

    • Proposed as answer by Dennis Guo Thursday, March 3, 2016 6:24 AM
    • Marked as answer by Patrick_Liang Friday, March 4, 2016 10:54 AM
    Thursday, February 25, 2016 3:40 AM