SharePoint 2013 CTX variable and its function part 1

In this post going to show you some of the useful Utility Functions that might be useful for you while working with search display template. I used most of the functions

MSDN Link:

CTX: In Display template CTX variable is responsible for returning the all the managed properties and other DOM elements.

Utility Functions

String Functions: For checking Null, Undefined & empty values 

  • Srch.U.w(str): Indicates whether the given string is null, undefined, or empty.
  • $isNull(str): Checking for Null
  • Srch.U.n(str): Indicates whether the given object is null or undefined.
  • $isEmptyString(str): Checking for an empty string
  • Srch.U.e(str): Indicates whether the string is null or empty.

Array Functions: Split & other array related operations

  • Srch.U.getArray(property): Splits the string into an array of strings using the semi colon (";") as a separator.
  • Srch.U.isArray(obj):Indicates whether the specified object is an array or not.
  • Srch.U.isInArray(a, item): Indicates whether the specified item is in the array.
  • Srch.U.appendArray(a, item): Appends an element to an array.
  • $isEmptyArray(str): Return True if Array is having null value


Popular posts from this blog

SharePoint RPC Protocols Examples Using OWSSVR.DLL

STS CryptographicException Error : Key set does not exist

Query suggestions in SP 2013 Using Rest API (/_api/search/suggest)