diff --git a/src/app/helperFunctions/customTableFilterFunction.ts b/src/app/helperFunctions/customTableFilterFunction.ts index 3391cdd..c04b447 100644 --- a/src/app/helperFunctions/customTableFilterFunction.ts +++ b/src/app/helperFunctions/customTableFilterFunction.ts @@ -11,6 +11,9 @@ export function customTableFilterFunction(data: any, filter: any) { if (filterElement.type === 'String' || filterElement.type === 'Id') { let searchString = filterElement.value.trim(); let dataElement = data[filterElementName]?.trim(); + if (dataElement == null) { + return false; + } if (!filterElement.options.caseSensitive) { searchString = searchString.toLowerCase(); dataElement = dataElement.toLowerCase(); @@ -41,6 +44,32 @@ export function customTableFilterFunction(data: any, filter: any) { } } } + if (filterElement.type === 'NumRange') { + if ( + filterElement.minValue.min != null || + filterElement.minValue.max != null || + filterElement.maxValue.min != null || + filterElement.maxValue.max != null + ) { + let dataElementMin = data[filterElementName + '.min']; + let dataElementMax = data[filterElementName + '.max']; + if (dataElementMin == null && dataElementMax == null) { + return false; + } + if (filterElement.minValue.min != null && dataElementMin < filterElement.minValue.min) { + return false; + } + if (filterElement.minValue.max != null && dataElementMin > filterElement.minValue.max) { + return false; + } + if (filterElement.maxValue.min != null && dataElementMax < filterElement.maxValue.min) { + return false; + } + if (filterElement.maxValue.max != null && dataElementMax > filterElement.maxValue.max) { + return false; + } + } + } } /*const b = !filter.includesString ||