From 7c620b3d9df47551719a9e81a8c720878ebe129d Mon Sep 17 00:00:00 2001 From: Tyler Ball Date: Wed, 17 May 2017 09:47:44 -0700 Subject: [PATCH] fix(table): only perform filter if search string is present --- .../lib/data-source/local/local.data-source.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/ng2-smart-table/lib/data-source/local/local.data-source.ts b/src/ng2-smart-table/lib/data-source/local/local.data-source.ts index c456bc65f..619dc8cda 100644 --- a/src/ng2-smart-table/lib/data-source/local/local.data-source.ts +++ b/src/ng2-smart-table/lib/data-source/local/local.data-source.ts @@ -235,14 +235,18 @@ export class LocalDataSource extends DataSource { if (this.filterConf.filters) { if (this.filterConf.andOperator) { this.filterConf.filters.forEach((fieldConf: any) => { - data = LocalFilter - .filter(data, fieldConf['field'], fieldConf['search'], fieldConf['filter']); + if (fieldConf['search'].length > 0) { + data = LocalFilter + .filter(data, fieldConf['field'], fieldConf['search'], fieldConf['filter']); + } }); } else { let mergedData: any = []; this.filterConf.filters.forEach((fieldConf: any) => { - mergedData = mergedData.concat(LocalFilter - .filter(data, fieldConf['field'], fieldConf['search'], fieldConf['filter'])); + if (fieldConf['search'].length > 0) { + mergedData = mergedData.concat(LocalFilter + .filter(data, fieldConf['field'], fieldConf['search'], fieldConf['filter'])); + } }); // remove non unique items data = mergedData.filter((elem: any, pos: any, arr: any) => {