Skip to content

Commit 1d06780

Browse files
committed
pass row index to format function on doing filter
1 parent 98a411c commit 1d06780

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/store/TableDataStore.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ export class TableDataStore {
383383

384384
_filter(source) {
385385
const filterObj = this.filterObj;
386-
this.filteredData = source.filter( row => {
386+
this.filteredData = source.filter((row, r) => {
387387
let valid = true;
388388
let filterVal;
389389
for (const key in filterObj) {
@@ -431,7 +431,7 @@ export class TableDataStore {
431431
formatExtraData = this.colInfos[key].formatExtraData;
432432
filterValue = this.colInfos[key].filterValue;
433433
if (filterFormatted && format) {
434-
targetVal = format(row[key], row, formatExtraData);
434+
targetVal = format(row[key], row, formatExtraData, r);
435435
} else if (filterValue) {
436436
targetVal = filterValue(row[key], row);
437437
}
@@ -457,7 +457,7 @@ export class TableDataStore {
457457
default: {
458458
if (filterObj[key].type === Const.FILTER_TYPE.SELECT &&
459459
filterFormatted && filterFormatted && format) {
460-
filterVal = format(filterVal, row, formatExtraData);
460+
filterVal = format(filterVal, row, formatExtraData, r);
461461
}
462462
valid = this.filterText(targetVal, filterVal);
463463
break;
@@ -480,7 +480,7 @@ export class TableDataStore {
480480
} else {
481481
searchTextArray.push(this.searchText);
482482
}
483-
this.filteredData = source.filter( row => {
483+
this.filteredData = source.filter((row, r) => {
484484
const keys = Object.keys(row);
485485
let valid = false;
486486
// for loops are ugly, but performance matters here.
@@ -499,7 +499,7 @@ export class TableDataStore {
499499
let targetVal = row[key];
500500
if (searchable) {
501501
if (filterFormatted && format) {
502-
targetVal = format(targetVal, row, formatExtraData);
502+
targetVal = format(targetVal, row, formatExtraData, r);
503503
} else if (filterValue) {
504504
console.log('inin');
505505
targetVal = filterValue(targetVal, row);

0 commit comments

Comments
 (0)