Sunday, 29 June 2014

SharePoint 2013 – Search results count


Open Control Template
Add below code to find search result count
<div class="ms-srch-resultFooter">
<!--#_
if(ctx.ClientControl.get_showResultCount() && ctx.DataProvider.get_totalRows() > 0){
var start = ctx.DataProvider.get_currentQueryState().s;
var resultsPerPage = ctx.DataProvider.get_resultsPerPage();
var totalRows = ctx.DataProvider.get_totalRows();
var countDisplayString = Srch.Res.rs_ApproximateResultCount;
if (start + resultsPerPage > totalRows) { countDisplayString = (totalRows == 1)? Srch.Res.rs_SingleResultCount : Srch.Res.rs_ResultCount; }
_#-->
<div id="ResultCount" class="ms-srch-resultscount">
_#= String.format($htmlEncode(countDisplayString), $htmlEncode(totalRows.localeFormat("N0"))) =#_
</div>
<!--#_
}
=============================

var totalRows = ctx.DataProvider.get_totalRows();