Index: simple_grid.js =================================================================== --- simple_grid.js (revision 13756) +++ simple_grid.js (working copy) @@ -128,13 +128,30 @@ } SimpleGrid.prototype.removeRecord = function ($number) { + var $index = array_search($number, this.ItemIDs); + + if ($index == -1) { + // don't allow to delete missing rows + return false; + } + this.getControl('container').removeChild( this.getControl($number) ); - var $index = array_search($number, this.ItemIDs); + this.ItemIDs.splice($index, 1); + this.renumberRecords(); this.updateTotals(); + + return true; } +SimpleGrid.prototype.removeRecords = function () { + while (this.ItemIDs.length > 0) { + var $item_id = this.ItemIDs[this.ItemIDs.length - 1]; + this.removeRecord($item_id); + } +} + SimpleGrid.prototype.updateTotals = function () { // prototype }