Фильтр таблицы угловых материалов с вложенным объектом - PullRequest
1 голос
/ 23 октября 2019

У меня есть два массива в моем объекте, что приводит к тому, что я могу фактически фильтровать один массив, но не второй.

Это мой предикат фильтра, который отлично работает для массива районов,но не для массива propertyType. У кого-то есть идея, как фильтровать и второй массив?

this.dataSource.filterPredicate = (data, filter: string)  => {
  const accumulator = (currentTerm, key) => {
    return key === 'district' ? currentTerm + data.district.name : currentTerm + data[key];
  };
  const dataStr = Object.keys(data).reduce(accumulator, '').toLowerCase();
  // Transform the filter by converting it to lowercase and removing whitespace.
  const transformedFilter = filter.trim().toLowerCase();
  return dataStr.indexOf(transformedFilter) !== -1;
};

Интерфейс

export interface Property {
   city: string;
   description: string;
   district: District; <-- here
   efficiencyRating: EfficiencyRating; <-- here
   houseno: string;
   id: number;
   name: string;
   propertyType: PropertyType; <-- here 
}
...