2022.2

Table Of Contents
InallothercasesyouwillneedaStandardScript.
Thistopicgivessomeinformationthatwillhelpyoutowriteascriptfor(anelementin)aDynamic
Table.
Itisassumedthatyouarefamiliarwiththescriptingbasics;see"Writingyourownscripts"onpage368.
WritingscriptsforaDynamicTable
Ifyou'regoingtocreateyourownscriptsforDynamicTables,thereareafewthingsyouneedtoknow.
Selectors
Scriptsthattarget(anelementin)aDynamicTablecanusethesametypesofselectorsasother
scripts.Intheoutput,DynamicTablerowsarerepeatedincludinganyclassesthataresetontherow
andonitscontents.
Inaddition,DynamicTablesandtheirrowsandcellshavesomespecialdata- attributesthatcanbe
usedasselector.See:ADynamicTable'sdata-attributes.
Notehowever,thatthedata-repeatattributecannotbeusedasaselectorforStandardscripts,since
itgetsremovedwhenthetableisexpanded,whichhappensbeforeStandardscriptsrun.
Thedata-scriptattributeisusedifyoulettheDesignercreateascriptforyou(see"Quick-starta
scriptwiththeCreatescriptbutton"onthefacingpage).
How the scope of a script can simplify code
Itisrecommendedtosetthescopeofascriptthattargets(anelementin)dynamicallyaddedrowsto
Each matched element.
Theselectorofascriptthattargets(somethingin)arowthatislinkedtoadetailtablewillprobably
matchmultipleelements.
Bysettingthescopeofascriptyoucandeterminewhetheryouwanttorunthescriptonce,oronce for
each elementthatmatchestheselector.(See"Settingthescopeofascript"onpage373.)
Ifascriptrunsonce,accessingthedetaildataanddynamicallyaddedrowstendstobeabitcom-
plicated,especiallywhentheyarenested,sinceitinvolvesloopingovertheresultsandrecordobjects
(see"results"onpage844and"record"onpage744).
Ifascripttargets(somethingin)arowthatisboundtoadetailtable,andrunsonce for each matched
element,thecurrentelementisaccessibleviathethisobject(see"this"onpage781)andthecurrent
detailrecordisaccessibleviathis.record.
Theadvantageofthelatterapproachisdemonstratedinanexamplebelow.
Quick-startascriptwiththeCreatescriptbutton
Thisquick-startprocedureonlyworksforelements(acellorspan)thathaveadirectlinkwithadata
field.
Page 395