Created
December 3, 2014 08:18
-
-
Save estruyf/01ecd39b249fec534ae8 to your computer and use it in GitHub Desktop.
SPSUK Demo Refreshing results (Control template)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html xmlns:mso="urn:schemas-microsoft-com:office:office" xmlns:msdt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"> | |
<head> | |
<title>Refresh Results</title> | |
<!--[if gte mso 9]><xml> | |
<mso:CustomDocumentProperties> | |
<mso:TemplateHidden msdt:dt="string">0</mso:TemplateHidden> | |
<mso:MasterPageDescription msdt:dt="string">This is the default Control Display Template that will list the items. It does not allow the user to page through items.</mso:MasterPageDescription> | |
<mso:ContentTypeId msdt:dt="string">0x0101002039C03B61C64EC4A04F5361F385106601</mso:ContentTypeId> | |
<mso:TargetControlType msdt:dt="string">;#Content Web Parts;#</mso:TargetControlType> | |
<mso:HtmlDesignAssociated msdt:dt="string">1</mso:HtmlDesignAssociated> | |
<mso:HtmlDesignConversionSucceeded msdt:dt="string">True</mso:HtmlDesignConversionSucceeded> | |
<mso:HtmlDesignStatusAndPreview msdt:dt="string">http://intranet/sites/SPSUK/_catalogs/masterpage/SPSUK/RefreshResults/Control_Refresh.html, Conversion successful.</mso:HtmlDesignStatusAndPreview> | |
</mso:CustomDocumentProperties> | |
</xml><![endif]--> | |
</head> | |
<body> | |
<script> | |
Type.registerNamespace('search.Refresh'); | |
search.Refresh = function() { | |
var currentCtx; | |
return { | |
setCurrentCtx: function (ctx) { | |
currentCtx = ctx; | |
}, | |
refreshResults: function () { | |
// Initiate the query | |
currentCtx.DataProvider.issueQuery(); | |
} | |
} | |
}(); | |
Srch.U.registerRenderTemplateByName("setcurrentctx", search.Refresh.setCurrentCtx); | |
Srch.U.registerRenderTemplateByName("refreshsearchresults", search.Refresh.refreshResults); | |
</script> | |
<div id="Control_List"> | |
<!--#_ | |
setTimeout(function () { Srch.U.getRenderTemplateCollection().refreshsearchresults(); }, 5000); | |
// Set the current context | |
Srch.U.getRenderTemplateCollection().setcurrentctx(ctx); | |
if (!$isNull(ctx.ClientControl) && | |
!$isNull(ctx.ClientControl.shouldRenderControl) && | |
!ctx.ClientControl.shouldRenderControl()) | |
{ | |
return ""; | |
} | |
ctx.ListDataJSONGroupsKey = "ResultTables"; | |
var $noResults = Srch.ContentBySearch.getControlTemplateEncodedNoResultsMessage(ctx.ClientControl); | |
var noResultsClassName = "ms-srch-result-noResults"; | |
var ListRenderRenderWrapper = function(itemRenderResult, inCtx, tpl) | |
{ | |
var iStr = []; | |
iStr.push('<li>'); | |
iStr.push(itemRenderResult); | |
iStr.push('</li>'); | |
return iStr.join(''); | |
} | |
ctx['ItemRenderWrapper'] = ListRenderRenderWrapper; | |
var retrievalDate = new Date(); | |
retrievalDate = retrievalDate.format('HH:mm:ss'); | |
_#--> | |
<div class="results"> | |
<h3> | |
Refresh results: <a href="#" onclick="Srch.U.getRenderTemplateCollection().refreshsearchresults()" title="Refresh Results" class="refresh-results" style="display: inline-block;height: 17px;margin: 0 2px;overflow: hidden;position: relative;width: 15px;"> | |
<img src='/_layouts/15/images/spcommon.png' style="left: -5px;position: absolute;top: -130px;"> | |
</a> - _#= retrievalDate =#_ | |
</h3> | |
<ul class="cbs-List"> | |
_#= ctx.RenderGroups(ctx) =#_ | |
</ul> | |
</div> | |
<!--#_ | |
if (ctx.ClientControl.get_shouldShowNoResultMessage()) | |
{ | |
_#--> | |
<div class="_#= noResultsClassName =#_">_#= $noResults =#_</div> | |
<!--#_ | |
} | |
_#--> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment