Enhancing AARI Table Fields
Table Operations
Reading All Rows in a Table
Add the “Read AARI Table Field” brick
⚠️ If you are using the brick in a Trigger, set the Root Mode of the brick to
Document
. If set to Inherit, PixieBrix will not find the table because it will search within the element that triggered the event
Setting Cell Values in a Table
Add the “Set AARI Table Field Values” brick
⚠️If you are using the brick in a Trigger, set the Root Mode of the brick to
Document
. If set to Inherit, PixieBrix will not find the table because it will search within the element that triggered the event
Handling Row Clicks
Add a Click handler targeting the table field, e.g.,
#Table1 tbody tr
When you click the row, the output of the brick with be available as an array at
@row.values
Reading a Column by Name
Add the "Read AARI Table Field Column” brick
Provide the table selector based on the field name of the table, e.g.,
#Table1
Provide the column heading to read, e.g.,
Column 1
⚠️If you are using the brick in a Trigger, set the Root Mode of the brick to
Document
. If set to Inherit, PixieBrix will not find the table because it will search within the element that triggered the event
Highlighting Cells
Add the “Highlight AARI Table Cells” brick
⚠️If you are using the brick in a Trigger, set the Root Mode of the brick to
Document
. If set to Inherit, PixieBrix will not find the table because it will search within the element that triggered the event
Appending a Row to a Table
Add the “Append AARI table row” brick
Provide the table selector based on the field name of the table, e.g.,
#Table1
Provide an array of values to write in the new row. You can also pass an array of values
⚠️ If you are using the brick in a Trigger, set the Root Mode of the brick to
Document
. If set to Inherit, PixieBrix will not find the table because it will search within the element that triggered the event
Table Validation and Calculations
Example: Checking Aggregate Values
Add the
@pixiebrix/jq
brickPass the output key of the “Read AARI Table Field” brick for the data property
The check if the value in the last row is equal to the sum of the proceeding columns, use the following jq filter:
Property Value filter
(.rows[-1]["Column 1"] | tonumber) == (.rows[0:-1] | map(.["Column 1"] | tonumber) | add)
data
@table
The (.rows[-1]["Column 1"] | tonumber)
expression gets the value in the last row and converts it to a number
The (.rows[0:-1] | map(.["Column 1"] | tonumber) | add)
expression gets the proceeding rows, converts the value in Column 1 to a number, and sums the values
Example: Multi-Column Validation
Add the
@pixiebrix/jq
brickPass the output key of the “Read AARI Table Field” brick for the data property
To report rows where the value in “Column 1” is greater than the value in “Column 2”, use the following jq filter:
Property Value filter
.rows | map((.["Column 1"] | tonumber) > (.["Column 2"] | tonumber)) | to_entries | map(select(.value)) | map({row: .key, column: 1})
data
@table
Pass the output of the jq brick to the Highlight AARI Table Cells brick
Writing Table Selectors
Table Selectors
The AARI Table Fields can each be targeted with a selector corresponding to the field in the form #Table0
, #Table1
Column Selectors
To target a particular column in the table, you can:
Target the column id:
#Table1 td:has(#Table1_col0-defaultValue)
. NOTE: the column id is not necessarily the column index. The column id is dependent on which order the the columns were added during AARI form creationTarget the column by index (1-indexed):
#Table1 td.preview-table__body-column:nth-child(1)
Known Limitations
“Attach Autocomplete” brick fills multiple cells when a value is selected
There is a known issue when selecting a value from Attach Autocomplete brick that it fills all the inputs matching the selector. (I.e., as opposed to only filling the input for which the autocomplete was shown)
Last updated