Skip to content

Commit

Permalink
fix: added dataManager in filterRows function
Browse files Browse the repository at this point in the history
  • Loading branch information
shariquerik authored Dec 21, 2023
1 parent 6d29880 commit 50b44bf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/datamanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
7 changes: 4 additions & 3 deletions src/filterRows.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 50b44bf

Please sign in to comment.