display.grid.findIndex()
The findIndex() method returns the index of the first record in the grid that satisfies the provided testing function. Otherwise -1 is returned.
Parameter
Callback function that receives the following arguments:
Record object with properties for each field in the grid
Index - the zero-based index of the current grid record being processed
Records array - array representing all of the grid records
The function must return true when the test condition is met.
Return Value
Zero-based index of the found record or -1.
 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 }
]);
// Find a record with quantity < 15
var foundRecordIndex = display.mygrid.findIndex(function(record) {
return (record.quantity < 15);
});
Â
console.log(foundRecordIndex); // Outputs 2