Enhancing AARI Table Fields
Last updated
Last updated
Add the “Read AARI Table Field” brick
Enter a selector for the field name of the table, e.g., #Table0
, #Table1
, etc. When you type in the selector, PixieBrix will highlight the table:
⚠️ 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
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
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
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
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
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
Add the @pixiebrix/jq
brick
Pass 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:
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
Add the @pixiebrix/jq
brick
Pass 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:
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
The AARI Table Fields can each be targeted with a selector corresponding to the field in the form #Table0
, #Table1
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 creation
Target the column by index (1-indexed): #Table1 td.preview-table__body-column:nth-child(1)
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)
Set the target mode to root
. By setting the mode to root
the trigger will pass along the row element, even if the use clicks on a cell or input within the row
Add the “Read AARI Table Field Row” brick and rename the output key to row
Leave the rowSelector
blank and set the Root Mode to Inherit
for the brick to read from the row that was clicked