component.updateFilter(true);
};
+ describe('searchableObjects', () => {
+ const testObject = {
+ obj: {
+ min: 8,
+ max: 123
+ }
+ };
+
+ beforeEach(() => {
+ component.data = [testObject];
+ component.columns = [{ prop: 'obj', name: 'Object' }];
+ });
+
+ it('should not search through objects as default case', () => {
+ expect(component.searchableObjects).toBe(false);
+ expectSearch('8', []);
+ });
+
+ it('should search through objects if searchableObjects is set to true', () => {
+ component.searchableObjects = true;
+ expectSearch('28', []);
+ expectSearch('8', [testObject]);
+ expectSearch('123', [testObject]);
+ expectSearch('max', [testObject]);
+ });
+ });
+
it('should find a particular number', () => {
expectSearch('5', [{ a: 5, b: 50, c: true }]);
expectSearch('9', [{ a: 9, b: 90, c: true }]);
@Input()
autoSave = true;
+ // Enable this in order to search through the JSON of any used object.
+ @Input()
+ searchableObjects = false;
+
// Only needed to set if the classAddingTpl is used
@Input()
customCss?: { [css: string]: number | string | ((any) => boolean) };
} else if (_.isNumber(cellValue) || _.isBoolean(cellValue)) {
cellValue = cellValue.toString();
}
+
+ if (_.isObjectLike(cellValue)) {
+ if (this.searchableObjects) {
+ cellValue = JSON.stringify(cellValue);
+ } else {
+ return false;
+ }
+ }
+
return cellValue.toLowerCase().indexOf(searchTerm) !== -1;
}).length > 0
);