some tricks in a custom query template (in a grid) or in a HTML cell on a form
To reformat a date field. Can be used in a custom layout for a combo box, per How can I format a Date in a HTML custom layout template?
# var d = kendo.parseDate (data["NameOfYourDateOrTimestampAttribute"], "MM/dd/yyyy HH:mm"); #
# var s = kendo.toString (d, "MMM dd yyyy"); #
<span>
#= s #
</span>
To suppress UNDEFINED in a custom layout (this simply omits the field), per WORKAROUND! Query custom display settings {attribute} value
# if (data["theAwareField"]){ #
<span class="text-primary">{theAwareField}</span>
# } #
Or use an else statement to print something else
# if (data["theAwareField"]){ #
<span class="text-primary">{theAwareField}</span>
# } else { #
<span class="text-primary">No Value</span>
# } #
Conditional Colors in Custom Query, per Help with custom query display
example 1 - color a person's name blue or pink based on gender
# if(data["Gender"] == "M") { #
<div class="Male">{Name}</div>
# } else { #
<div class="Female">{Name}</div>
# } #
example 2 - conditionally color the invoice AGE field based on daysOld field
<div>
# if( data["daysOld"] > 14 ) { # <span class="redBold"> # }
else if ( data["daysOld"] > 6 ) { # <span class="yellowBold"> # }
else { # <span class="greenBold"> # }
#
<div class="optionalClass">{age}</div>
</span>
</div>
Perhaps there are multiple phone fields. Print a phone if it exists:
Phones:
# if( Phone1.data != 'null') { #
{Phone1}
#} #
# if( Phone2.data != 'null') { #
{Phone2}
#} #
another example (SEE NOTE FOR V9)
# if(data["Email"] != undefined) { # <div class='licinfo-email'>Email: {Email}</div> #} #
# if(data["Email"] == undefined) { # <div class='licinfo-email-missing'>No Email on File</div> #} #
NOTE: It was reported by Joben in April 2024 that the above syntax stopped working after upgrade to v9.
Code was changed to this:
# if(data["Email"] != "") { # <div>{Email}</div> # } #
# if(data["Email"] == "") { # <div>No Email on File</div> # } #
--> jaymerTip