2022.2

Table Of Contents
Thecodeofthescriptreplacesthecontentsoftheelementwiththecurrentvalueofthedatafield:
var field = this.record.fields['ID'];
if (field) {
this.text(formatter.upperCase(field));
}
UnderOptions,thescopeofthescriptissettoEach matched element(see"Settingthescopeofa
script"onpage813).Thismeansthatinthecode,thisreferstotheelementthatmatchestheselector,
andthis.recordreferstothecurrent (nested) detail record(see"this"onpage1237).
Tip: Togetaccesstotherowinwhichthecellislocated,youcanusethis.parent().
Note: Ifyoubindtheelementtoadatafieldagainbyselectingitandthenselectingafieldfrom
theFielddrop-downontheAttributespane,thedata-scriptattributewillberemoved.
Example:Stylingarowbasedonavalueinadetailtable
Herearetwoscriptsthathavethesameeffect:ifinarow,thevalueofthefieldShippedis1,itcolors
thetextofthatrowgreen.
ThefirstscripttargetsacellinaDynamicTablerowthathasa[data-script='Shipped']attribute.The
scripthasitsscopesetto"Eachmatchedelement",soitcanusethis(see"this"onpage1237)to
accesstheselectedcellandthis.recordtoaccessthecurrentdetailrecord,withoutperformingany
loops.
Selector:table[data-script='Shipped'].
Scope:Eachmatchedelement
var field = this.record.fields['Shipped'];
if (field == 1)
this.parent().css('color', 'green');
Page 837