fix: added dataManager in filterRows function

This commit is contained in:
Shariq Ansari 2023-12-21 13:13:41 +05:30 committed by GitHub
parent 6d29880fb7
commit 50b44bfb09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -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();

View File

@ -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);