Browse Source

fix: Loop Stops Processing Rows When Column is Missing (#7365)

* fix: ensure loop continues when column is not found

- Replace `return` with `continue` to properly iterate over all columns
- Prevents early exit of loop when a column is missing, ensuring all columns are processed correctly

* fixes after review
Sokolovskiyi Serhii 1 year ago
parent
commit
5c1da3bdf5
1 changed files with 4 additions and 3 deletions
  1. 4 3
      src/bootstrap-table.js

+ 4 - 3
src/bootstrap-table.js

@@ -2509,15 +2509,16 @@ class BootstrapTable {
     }
 
     if (params && params.formatted) {
-      data.forEach(row => {
+      return data.map(row => {
         for (const [key, value] of Object.entries(row)) {
           const column = this.columns[this.fieldsColumnsIndex[key]]
 
           if (!column) {
-            return
+            continue
           }
 
-          row[key] = Utils.calculateObjectValue(column, this.header.formatters[column.fieldIndex], [value, row, row.index, column.field], value)
+          return Utils.calculateObjectValue(column, this.header.formatters[column.fieldIndex],
+            [value, row, row.index, column.field], value)
         }
       })
     }