display.grid.find()



The find() method returns the first record in the grid that satisfies the provided testing function. Otherwise undefined is returned.



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

An object representing the found record, with properties for each field in the grid. The object is a copy of the record. Modifying the object will not modify the record 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 }, { product: 4, description: "ITEM FOUR", quantity: 18 } ]); // Find a record with quantity < 15 var foundRecord = display.mygrid.find(function(record) { return (record.quantity < 15); });   console.log(foundRecord);   // The line above will log the following output: // { product: 3, description: 'ITEM THREE', quantity: 12 }