Pages

Search This Blog

Monday, August 17, 2015

SharePoint Increase search result items limit of Content Search Web Part by using javascript




SharePoint Content Search Web Part allow to show search results upto 50 Items per page.
Out Of The Box you cant allow it to show more than 50 Items per page.

But there may be situations with business needs where you need to override this behavior.
So here is javascript snippet which overrides this behavior and allows more than 50 items in search result.

How to use :

1. Add a Script Editor web part on the same page where Content Search web part is present.
2. Paste the following script and change the maxItems value as per your needs.
3. The script grabs the 2 SharePoint search objects ContentBySerach and DataProvider and overrides it default value to show more than 50 items.



<script type="text/javascript">

var $ocreate = null, maxItems = 100;

Sys.Application.add_init(function() {
$ocreate = $create; $create = updateResultCountCreate;
});

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);
}
</script>

  

No comments:

Post a Comment