LP#1775466 Grid pageOffset option continued
authorBill Erickson <berickxx@gmail.com>
Thu, 12 Jul 2018 16:35:12 +0000 (12:35 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 12 Jul 2018 21:33:54 +0000 (17:33 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/share/grid/grid.ts

index b3e373e..45d2525 100644 (file)
@@ -432,21 +432,24 @@ export class GridContext {
         return this.getRowColumnValue(row, col);
     }
 
-    // Returns the array position of the row-by-index in the
-    // dataSource array.
+    // Returns position in the data source array of the row with
+    // the provided index.
     getRowPosition(index: any): number {
         // for-loop for early exit
         for (let idx = 0; idx < this.dataSource.data.length; idx++) {
-            if (index === this.getRowIndex(this.dataSource.data[idx])) {
+            const row = this.dataSource.data[idx];
+            if (row !== undefined && index === this.getRowIndex(row)) {
                 return idx;
             }
         }
     }
 
+    // Return the row with the provided index.
     getRowByIndex(index: any): any {
         for (let idx = 0; idx < this.dataSource.data.length; idx++) {
-            if (index === this.getRowIndex(this.dataSource.data[idx])) {
-                return this.dataSource.data[idx];
+            const row = this.dataSource.data[idx];
+            if (row !== undefined && index === this.getRowIndex(row)) {
+                return row;
             }
         }
     }