2022.2

Table Of Contents
tr:first-child {
background: red;
}
Tip: InaDynamicTable,dataareinthebodyofthetable(selector:tbody)andsubtotalsarein
thefooter(selector:tfoot).
Selecting a specific row, odd or even rows, or every nth row
Thepseudo-class:nth-child()letsyouselectaspecificrow,alloddorevenrows,oreverynthrow.
Betweentheroundbracketsin:nth-child()youcanfillinanumber,oddoreven,oraformula:
an+b.Intheformula,arepresentsacyclesize(every...),nisacounter(forthechildelements),andb
isanoffsetvalue('startatb').Thefollowingexampleswillmakethisclear.
:nth-child(3)matchesjustoneelement:thethirdchildelement.
:nth-child(odd)matcheschildelements1,3,5,7,etc.Thekeywordodd substitutestheexpres-
sion2n+1,whichinotherwordssays:'takeeverysecondelement,startingat1'.
:nth-child(even)matcheschildelements2,4,6,8,etc.Thekeywordeven substitutestheexpres-
sion2n+0,orsimply2n.
:nth-child(3n)matcheschildelements3,6,9,12etc.
:nth-child(3n+1)matcheschildelements1,4,7,10etc.,soeverythirdelement,startingat1.
Viascript(basedonadatafieldvalue)
Tostyleatable,roworcellbasedonadatafieldvalue,youhavetowriteascript(see"Writingyourown
scripts"onpage808).
FirstaddanIDorclasstothetable,roworcellthatneedstobestyled:selecttheelement(see"Select-
ingatable,roworcell"onpage689)andaddanIDontheAttributespane.Thencreateascript,using
thatIDorclassasthescript'sselector.Thescriptcanbeverysimple:
if (record.fields.COUNTRY == 'CANADA') {
results.css('color','green');
}
TheDesignerScriptsAPIprovidesseveralfunctionstostyleelements,forexamplecss(),hasClass
()andaddClass()(see"StandardScriptAPI"onpage1169).
ForinformationregardingscriptsforDynamic Tables,see"UsingscriptsinDynamicTables"on
page835.
Page 692