}
grid.prepend = function(limit) {
+ var ran_into_duplicate = false;
+ var sort = grid.dataProvider.sort;
+ if (sort && sort.length) {
+ // if sorting is in effect, we have no
+ // have no way here of knowing which row
+ // was most recently added nor that it
+ // belongs on top of the visible set of rows,
+ // so we default to a full collect()
+ grid.collect();
+ return;
+ }
if (grid.offset > 0) {
// if we're prepending, we're forcing the
// offset back to zero to display the top
null,
function(item) {
if (item) {
+ var newIdx = grid.indexValue(item);
+ angular.forEach($scope.items, function(existing) {
+ if (grid.indexValue(existing) == newIdx) {
+ console.debug('egGrid.prepend(): refusing to add duplicate item ' + newIdx);
+ ran_into_duplicate = true;
+ return;
+ }
+ });
$scope.items.unshift(item);
if (limit && $scope.items.length > limit) {
// this accommodates the checkin grid that
console.debug('egGrid.prepend() complete');
grid.collecting = false;
$scope.selected = angular.copy($scope.selected);
+ if (ran_into_duplicate) {
+ grid.collect();
+ }
});
}