* Added a new option to the getData method to get the formatted values * Changed the way to check if a column exists * code style Co-authored-by: zhixin <wenzhixin2010@gmail.com>
@@ -188,6 +188,7 @@ The calling method syntax: `$('#table').bootstrapTable('method', parameter)`.
* `useCurrentPage`: if set to true the method will return the data only in the current page.
* `includeHiddenRows`: if set to true the method will include the hidden rows.
* `unfiltered`: if set to true the method will include all data (unfiltered).
+ * `formatted`: get the formatted value from the defined [formatter](https://bootstrap-table.com/docs/api/column-options/#formatter).
- **Example:** [Get Data](https://examples.bootstrap-table.com/#methods/getData.html)
@@ -2127,6 +2127,19 @@ class BootstrapTable {
})
}
+ if (params && params.formatted) {
+ data.forEach((row) => {
+ for (const [key, value] of Object.entries(row)) {
+ const column = this.columns[this.fieldsColumnsIndex[key]]
+ if (!column) {
+ return
+ }
+
+ row[key] = Utils.calculateObjectValue(column, this.header.formatters[column.fieldIndex], [value, row, row.index, column.field], value)
+ })
return data