Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Current »

Content Freeze

As of July 25th, 2023, there is a content freeze on this page.

The every() method tests whether all records in the grid pass the test implemented by the provided function.


Parameter

  1. Callback function that receives the following arguments:
    1. Record object with properties for each field in the grid
    2. Index - the zero-based index of the current grid record being processed
    3. Records array - array representing all of the grid records

The function must return true when the test condition is met.


Return Value

Returns true if the callback function returns a true value for every grid record; otherwise, false.


 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 },
  { product: 4, description: "ITEM FOUR", quantity: 18 }
]);

// Check if every grid record has a quantity greater than 0
var returnValue = display.mygrid.every(function(record) {
  return (record.quantity > 0);
});
 
console.log(returnValue);  // Outputs true
  • No labels