Skip to content
This repository was archived by the owner on Jun 1, 2025. It is now read-only.

Commit 25c0a52

Browse files
Ghislain BeaulacGhislain Beaulac
authored andcommitted
refactor(filter): simply use dot notation to detect complex object
1 parent 525f00a commit 25c0a52

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

src/app/examples/grid-clientside.component.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,18 @@ export class GridClientSideComponent implements OnInit {
9797
},
9898
{ id: 'utcDate', name: 'UTC Date', field: 'utcDate', formatter: Formatters.dateTimeIsoAmPm, sortable: true, minWidth: 115,
9999
type: FieldType.dateUtc, outputType: FieldType.dateTimeIsoAmPm, filterable: true, filter: { model: Filters.compoundDate } },
100-
{ id: 'effort-driven', name: 'Effort Driven', field: 'effortDriven.isEffort', minWidth: 85, maxWidth: 85,
100+
{
101+
id: 'effort-driven', name: 'Effort Driven', field: 'effortDriven.isEffort', minWidth: 85, maxWidth: 85,
101102
type: FieldType.boolean,
102103
sortable: true,
103-
filterable: true,
104+
104105
// to pass multiple formatters, use the params property
105106
// also these formatters are executed in sequence, so if you want the checkmark to work correctly, it has to be the last formatter defined
106107
formatter: Formatters.multiple,
107108
params: { formatters: [Formatters.complexObject, Formatters.checkmark] },
109+
110+
// when the "field" string includes the dot "." notation, the library will consider this to be a complex object and Filter accordingly
111+
filterable: true,
108112
filter: {
109113
// We can also add HTML text to be rendered (any bad script will be sanitized) but we have to opt-in, else it will be sanitized
110114
// enableRenderHtml: true,
@@ -115,7 +119,6 @@ export class GridClientSideComponent implements OnInit {
115119
value: 'isEffort',
116120
label: 'label'
117121
},
118-
isComplexObject: true,
119122
model: Filters.singleSelect,
120123

121124
// we could add certain option(s) to the "multiple-select" plugin

src/app/modules/angular-slickgrid/models/columnFilter.interface.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,6 @@ export interface ColumnFilter {
7171
/** Do we want the Filter to handle translation (localization)? */
7272
enableTranslateLabel?: boolean;
7373

74-
/**
75-
* Defaults to false, does the filter has to deal with item that are complex object?
76-
* If so, it will explode the object using the dot "." notation to find the value to filter against.
77-
*/
78-
isComplexObject?: boolean;
79-
8074
/**
8175
* Use "params" to pass any type of arguments to your Custom Filter
8276
* for example, to pass a second collection to a select Filter we can type this:

src/app/modules/angular-slickgrid/services/filter.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,8 @@ export class FilterService {
191191
const filterSearchType = (columnDef.filterSearchType) ? columnDef.filterSearchType : null;
192192
let cellValue = item[fieldName];
193193

194-
// when item is a complex object, we need to filter the value contained in the object following the dot "." notation
195-
if (columnDef && columnDef.filter && columnDef.filter.isComplexObject) {
194+
// when item is a complex object (dot "." notation), we need to filter the value contained in the object tree
195+
if (fieldName.indexOf('.') >= 0) {
196196
cellValue = getDescendantProperty(item, fieldName);
197197
}
198198

0 commit comments

Comments
 (0)