From 50b44bfb090139831f9c7b23b270e67087843d2d Mon Sep 17 00:00:00 2001 From: Shariq Ansari <30859809+shariquerik@users.noreply.github.com> Date: Thu, 21 Dec 2023 13:13:41 +0530 Subject: [PATCH] fix: added dataManager in filterRows function --- src/datamanager.js | 2 +- src/filterRows.js | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/datamanager.js b/src/datamanager.js index c845a1c..bb60082 100644 --- a/src/datamanager.js +++ b/src/datamanager.js @@ -427,7 +427,7 @@ export default class DataManager { } filterRows(filters) { - return this.options.filterRows(this.rows, filters) + return this.options.filterRows(this.rows, filters, this) .then(result => { if (!result) { result = this.getAllRowIndices(); diff --git a/src/filterRows.js b/src/filterRows.js index 125c02f..a8f515f 100644 --- a/src/filterRows.js +++ b/src/filterRows.js @@ -1,7 +1,7 @@ import { isNumber, stripHTML } from './utils'; import CellManager from './cellmanager'; -export default function filterRows(rows, filters) { +export default function filterRows(rows, filters, data) { let filteredRowIndices = []; if (Object.keys(filters).length === 0) { @@ -18,7 +18,7 @@ export default function filterRows(rows, filters) { const cells = filteredRows.map(row => row[colIndex]); let filter = guessFilter(keyword); - let filterMethod = getFilterMethod(rows, filter); + let filterMethod = getFilterMethod(rows, filter, data); if (filterMethod) { filteredRowIndices = filterMethod(filter.text, cells); @@ -30,9 +30,10 @@ export default function filterRows(rows, filters) { return filteredRowIndices; }; -function getFilterMethod(rows, filter) { +function getFilterMethod(rows, filter, data) { const getFormattedValue = cell => { let formatter = CellManager.getCustomCellFormatter(cell); + data if (formatter && cell.content) { cell.html = formatter(cell.content, rows[cell.rowIndex], cell.column, rows[cell.rowIndex], filter); return stripHTML(cell.html);