Prices with cents and a $ sign
->numeric(decimals: 2) takes up to two decimal places and shows them in every cell. ->prefix('$') puts a $ sign in front of each price.
Note: Try it
Type 49.5 in 10+ × Member and leave the cell: it shows 49.50. Type 49.555 and click “Show what would be saved”: a message under the table asks for no more than 2 decimal places.
|
Quantity
|
Retail
|
Member
|
|---|---|---|
|
1+
|
|
|
|
10+
|
|
|
|
50+
|
|
|
Leave it empty and press Enter to clear the cells.
Columns in groups
Give ->columns() an array of arrays: the outer keys (Shoppers, Businesses) are written over their columns. Rows can be grouped the same way.
Note: Try it
Look at the top of the table: Retail and Member are under Shoppers, Reseller and Wholesale under Businesses. The saved array has no groups in it — click “Show what would be saved”.
|
Quantity
|
Shoppers | Businesses | ||
|---|---|---|---|---|
|
Retail
|
Member
|
Reseller
|
Wholesale
|
|
|
1+
|
|
|
|
|
|
10+
|
|
|
|
|
|
50+
|
|
|
|
|
Leave it empty and press Enter to clear the cells.
The average under each column
->totals(rows: false, columns: true) adds a row under the table, and ->totalsUsing('average') makes it the average instead of the sum (a sum of prices means nothing). Also: count, min and max.
Note: Try it
Change 1+ × Retail from $59.00 to $65.00: the average under Retail goes from $54.48 to $56.48 as you type.
|
Quantity
|
Retail
|
Member
|
|---|---|---|
|
1+
|
|
|
|
10+
|
|
|
|
50+
|
|
|
| Average | $54.48 | $49.03 |
Leave it empty and press Enter to clear the cells.