display.grid.insert()



The insert() method inserts a new record somewhere in the middle of a grid.



Parameters

  1. Start index - Index at which to start inserting into the grid (with origin 0). If greater than the total number of records in the grid, actual starting index will be set to the total number of records. If negative, insertion will begin that many elements from the end of the grid records (with origin 1).

  2. JavaScript object to insert with properties representing fields in the grid

  3. One or more additional JavaScript objects to insert (optional)



Example

pjs.defineDisplay("display.json"); // assume display.json defines mygrid with fields named "product" and "description" display.mygrid.addRecords([ { product: 1, description: "ITEM ONE" }, { product: 2, description: "ITEM TWO" }, { product: 3, description: "ITEM THREE" }, { product: 4, description: "ITEM FOUR" } ]);   display.mygrid.insert(2, { product: 2.5, description: "TWO AND A HALF" });