Skip to content

Commit 583940f

Browse files
prx-lmomportuga
authored andcommitted
[hotfix/7187]
- exchanged filter() with every()
1 parent 42e172b commit 583940f

File tree

1 file changed

+25
-12
lines changed
  • packages/core/src/js/factories

1 file changed

+25
-12
lines changed

packages/core/src/js/factories/Grid.js

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -686,11 +686,15 @@ angular.module('ui.grid')
686686
* @param {string} name column name
687687
*/
688688
Grid.prototype.getColumn = function getColumn(name) {
689-
var columns = this.columns.filter(function (column) {
690-
return column.colDef.name === name;
689+
var result = null;
690+
lookInRows.every(function (row) {
691+
if ( column.colDef.name === name ) {
692+
result = row;
693+
return false;
694+
}
695+
return true;
691696
});
692-
693-
return columns.length > 0 ? columns[0] : null;
697+
return result;
694698
};
695699

696700
/**
@@ -701,10 +705,15 @@ angular.module('ui.grid')
701705
* @param {string} name column.field
702706
*/
703707
Grid.prototype.getColDef = function getColDef(name) {
704-
var colDefs = this.options.columnDefs.filter(function (colDef) {
705-
return colDef.name === name;
708+
var result = null;
709+
lookInRows.every(function (row) {
710+
if ( colDef.name === name ) {
711+
result = row;
712+
return false;
713+
}
714+
return true;
706715
});
707-
return colDefs.length > 0 ? colDefs[0] : null;
716+
return result;
708717
};
709718

710719
/**
@@ -1084,13 +1093,17 @@ angular.module('ui.grid')
10841093
*/
10851094
Grid.prototype.getRow = function getRow(rowEntity, lookInRows) {
10861095
var self = this;
1096+
lookInRows = lookInRows == void 0 ? this.rows : lookInRows;
10871097

1088-
lookInRows = typeof(lookInRows) === 'undefined' ? self.rows : lookInRows;
1089-
1090-
var rows = lookInRows.filter(function (row) {
1091-
return self.options.rowEquality(row.entity, rowEntity);
1098+
var result = null;
1099+
lookInRows.every(function (row) {
1100+
if ( self.options.rowEquality(row.entity, rowEntity) ) {
1101+
result = row;
1102+
return false;
1103+
}
1104+
return true;
10921105
});
1093-
return rows.length > 0 ? rows[0] : null;
1106+
return result;
10941107
};
10951108

10961109

0 commit comments

Comments
 (0)