Skip to content

Commit

Permalink
fix: pass rowData as 3rd param to the searchAs function
Browse files Browse the repository at this point in the history
  • Loading branch information
kouts committed Jan 8, 2022
1 parent ccd80ec commit 66eb291
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/helpers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,19 @@ function fieldFilter(items, filterFields) {
}

// Search method that also takes into account transformations needed
function findAny(dsSearchIn, dsSearchAs, obj, str) {
function findAny(dsSearchIn, dsSearchAs, rowData, str) {
// Convert the search string to lower case
str = String(str).toLowerCase()
for (const key in obj) {
for (const key in rowData) {
if (dsSearchIn.length === 0 || dsSearchIn.indexOf(key) !== -1) {
const value = String(obj[key]).toLowerCase()
const value = String(rowData[key]).toLowerCase()
for (const field in dsSearchAs) {
if (field === key) {
// Found key in dsSearchAs so we pass the value and the search string to a search function
// that returns true/false and we return that if true.
/* Check if dsSearchAs is a function (passed from the template) */
if (typeof dsSearchAs[field] === 'function') {
const res = dsSearchAs[field](value, str)
const res = dsSearchAs[field](value, str, rowData)
if (res === true) {
return res
}
Expand Down

0 comments on commit 66eb291

Please sign in to comment.