display.grid.reduce()
The reduce() method executes a reducer function (that you provide) on each record in the grid resulting in a single output value.
Parameter
Reducer function that receives the following arguments:
Accumulator
Record object with properties for each field in the grid
Return Value
An array containing the new records. Each array element is a JavaScript object with properties for each field in the grid.
 Example
pjs.defineDisplay("display.json"); // assume display.json defines mygrid with fields named "product", "description", and "quantity"
display.mygrid.addRecords([
{ product: 1, description: "ITEM ONE", quantity: 15 },
{ product: 2, description: "ITEM TWO", quantity: 20 },
{ product: 3, description: "ITEM THREE", quantity: 12 }
]);
var totalQuantity = display.mygrid.reduce((total, record) => total + record.quantity);
Â
console.log(totalQuantity); // should output 37