I have a display template that is working awesome but for the formatting of the Managed Property not displaying the date correctly. I do not want the time included in the display. I am still learning and really could use some help with this.
The code for the display template is below, in a hope that someone can provide me an answer quickly.
List Table Item-Countermeasures
0</mso:TemplateHidden> ListID','ListItemID','ContentTypeId','Link URL':'Path','Property 1':'Title','Property 2':'','Property 3':'','Property 4:'','Property 5':'','Property 6':'','Property 7':'','Property 8':'','Property 9':'','Property 10':'','FileExtension','SecondaryFileExtension'</mso:ManagedPropertyMapping> This is the item row template, use this template in combination with the List Table Control template.</mso:MasterPageDescription> 0x0101002039C03B61C64EC4A04F5361F385106603</mso:ContentTypeId> ;#SearchResults;#Content Web Parts;#</mso:TargetControlType> 1</mso:HtmlDesignAssociated> https://share.philips.com/sites/STS020170908232517/_catalogs/masterpage/Display Templates/Search/Item_List_Item-CM.html, Conversion successful.</mso:HtmlDesignStatusAndPreview> True</mso:HtmlDesignConversionSucceeded> </mso:CrawlerXSLFile> </mso:HtmlDesignPreviewUrl> </mso:CustomDocumentProperties> </xml>
var encodedId = $htmlEncode(ctx.ClientControl.get_nextUniqueId() + "tableitems");
var linkURL = $getItemValue(ctx, "Link URL"); linkURL.overrideValueRenderer($urlHtmlEncode); var iconURL = Srch.ContentBySearch.getIconSourceFromItem(ctx.CurrentItem);
var listID = $getItemValue(ctx, 'ListID'); var listItemID = $getItemValue(ctx, 'ListItemID'); var ContentTypeId = $getItemValue(ctx, 'ContentTypeId');
var startDate = new Date($getItemValue(ctx, "Start Date"));
var rowId = encodedId + "row"; var editCellId = rowId + "_cell";
var currentItemIdx = ctx.CurrentItemIdx + 1; var alternating = currentItemIdx % 2 === 0 ? "ms-alternating" : "";
if (currentItemIdx === 1) { _#-->
<!--#_
// Show the properties that aren't empty
for(var i = 1; i <= 10; i++) {
var property = $getItemValue(ctx, String.format("Property {0}", i));
if(property.managedPropertyName !== String.format("Property {0}", i)) {
var propertyName = typeof propertyNames[property.propertyLookupName] === "undefined" ? property.managedPropertyName : propertyNames[property.propertyLookupName];
_#-->
<th class="ms-vh2">
_#= propertyName =#_
<span id="_#= property.managedPropertyName.replace(/ /g, '-') =#_">
<span style="" class="sortarrow ms-sortarrowup-iconouter" ></span>
<a id="_#= property.managedPropertyName =#_ASC" href="#" title="Ascending" onclick="$getClientControl(this).sortOrRank('_#= property.managedPropertyName =#_ASC');return false;">
<img alt="Ascending" src="/_layouts/15/images/sortaz.gif">
</a>
<a id="_#= property.managedPropertyName =#_DES" href="#" title="Descending" onclick="$getClientControl(this).sortOrRank('_#= property.managedPropertyName =#_DES');return false;">
<img alt="Descending" src="/_layouts/15/images/sortza.gif">
</a>
</span>
</th>
<!--#_
}
}
_#-->
</tr>
</thead>
<tbody>
{1}", linkURL, property) : property; if (Object.prototype.toString.call(property.value) === '[object Date]') {value = property.value.format('MM/dd/yyyy'); }
_#-->
_#= value =#_
<!--#_
if (i === 1 && !listID.isEmpty && !listItemID.isEmpty && !ContentTypeId.isEmpty) {
var viewPropUrl = String.format('/_layouts/15/listform.aspx?ListId={0}&ID={1}&ContentTypeID={2}&Source={3}', listID, listItemID, ContentTypeId, window.location.href.split('#')[0]);
_#-->
<span title="Open Menu" class="NotificationDiv ms-ellipsis-a" rel="_#= viewPropUrl =#_" ref="_#= property =#_" path="_#= linkURL =#_" style="cursor: pointer; margin-top: 3px; float: right;">
<img alt="Open Menu" src="/_layouts/15/images/spcommon.png" class="ms-ellipsis-icon">
</span>
<!--#_
}
}
_#-->
</td>
<!--#_
}
}
_#-->
</tr>
Thank you in advance.
Dorinda
UPDATE: the template is now rendering but the format is still not correct. I need help getting this working please