Skip to content

Commit 22ff93e

Browse files
prx-lmomportuga
authored andcommitted
[hotfix/7187]
- using find() if possible
1 parent 583940f commit 22ff93e

File tree

1 file changed

+21
-4
lines changed
  • packages/core/src/js/factories

1 file changed

+21
-4
lines changed

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

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -686,10 +686,16 @@ angular.module('ui.grid')
686686
* @param {string} name column name
687687
*/
688688
Grid.prototype.getColumn = function getColumn(name) {
689+
if (angular.isFunction(this.columns.find)) {
690+
return this.columns.find(function (column) {
691+
return column.colDef.name === name;
692+
}) || null;
693+
}
694+
689695
var result = null;
690-
lookInRows.every(function (row) {
696+
this.columns.every(function (column) {
691697
if ( column.colDef.name === name ) {
692-
result = row;
698+
result = column;
693699
return false;
694700
}
695701
return true;
@@ -705,10 +711,16 @@ angular.module('ui.grid')
705711
* @param {string} name column.field
706712
*/
707713
Grid.prototype.getColDef = function getColDef(name) {
714+
if (angular.isFunction(this.options.columnsDefs.find)) {
715+
return this.options.columnsDefs.find(function (colDef) {
716+
return colDef.name === name;
717+
}) || null;
718+
}
719+
708720
var result = null;
709-
lookInRows.every(function (row) {
721+
this.options.columnsDefs.every(function (colDef) {
710722
if ( colDef.name === name ) {
711-
result = row;
723+
result = colDef;
712724
return false;
713725
}
714726
return true;
@@ -1094,6 +1106,11 @@ angular.module('ui.grid')
10941106
Grid.prototype.getRow = function getRow(rowEntity, lookInRows) {
10951107
var self = this;
10961108
lookInRows = lookInRows == void 0 ? this.rows : lookInRows;
1109+
if (angular.isFunction(lookInRows.find)) {
1110+
return lookInRows.find(function (row) {
1111+
return self.options.rowEquality(row.entity, rowEntity);
1112+
}) || null;
1113+
}
10971114

10981115
var result = null;
10991116
lookInRows.every(function (row) {

0 commit comments

Comments
 (0)