The splice() method changes the contents of a grid by removing existing records and/or adding new records.


  1. Start index - Index at which to start changing 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, changes will begin that many elements from the end of the grid records (with origin 1).

  2. Delete count - A number indicating the number of grid records to remove. If set to 0, no records are removed. If set to greater than the number of records left in the grid starting at the Start index, then all of the records through the end of the grid will be deleted. If omitted, all of the records beginning with Start index on through the end of the grid will be deleted.

  3. JavaScript object to insert at the Start index with properties representing fields in the grid (optional)

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


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.splice(1, 2, { product: 99, description: "NINETY NINE" });   console.log(display.mygrid.getRecords()); // The line above will log the following output: // [ { product: 1, description: 'ITEM ONE' }, // { product: 99, description: 'NINETY NINE' }, // { product: 4, description: 'ITEM FOUR' } ]