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

Commit bfc2780

Browse files
authored
Merge pull request #1444 from ghiscoding/bugfix/filterqueryoverride-values
fix: `filterQueryOverride` provide all search values
2 parents 99dd0e2 + 0eef5c0 commit bfc2780

File tree

6 files changed

+109
-134
lines changed

6 files changed

+109
-134
lines changed

docs/backend-services/OData.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,9 @@ E.g. you could listen for a specific column and the active OperatorType.custom i
229229
```ts
230230
backendServiceApi: {
231231
options: {
232-
filterQueryOverride: ({ fieldName, columnDef, columnFilterOperator, searchValue }) => {
232+
filterQueryOverride: ({ fieldName, columnDef, columnFilterOperator, searchValues }) => {
233233
if (columnFilterOperator === OperatorType.custom && columnDef?.id === 'name') {
234-
let matchesSearch = (searchValue as string).replace(/\*/g, '.*');
234+
let matchesSearch = searchValues[0].replace(/\*/g, '.*');
235235
matchesSearch = matchesSearch.slice(0, 1) + '%5E' + matchesSearch.slice(1);
236236
matchesSearch = matchesSearch.slice(0, -1) + '$\'';
237237

docs/backend-services/graphql/GraphQL-Filtering.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ E.g. you could listen for a specific column and the active `OperatorType.custom`
147147
```ts
148148
backendServiceApi: {
149149
options: {
150-
filterQueryOverride: ({ fieldName, columnDef, columnFilterOperator, searchValue }) => {
150+
filterQueryOverride: ({ fieldName, columnDef, columnFilterOperator, searchValues }) => {
151151
if (columnFilterOperator === OperatorType.custom && columnDef?.id === 'name') {
152152
// the `operator` is a string, make sure to implement this new operator in your GraphQL Schema
153-
return { field: fieldName, operator: 'Like', value: searchValue };
153+
return { field: fieldName, operator: 'Like', value: searchValues[0] };
154154
}
155155
},
156156
}

package.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@
5050
},
5151
"dependencies": {
5252
"@ngx-translate/core": "^15.0.0",
53-
"@slickgrid-universal/common": "~5.3.4",
54-
"@slickgrid-universal/custom-footer-component": "~5.3.4",
55-
"@slickgrid-universal/empty-warning-component": "~5.3.4",
56-
"@slickgrid-universal/event-pub-sub": "~5.3.4",
57-
"@slickgrid-universal/pagination-component": "~5.3.4",
58-
"@slickgrid-universal/row-detail-view-plugin": "~5.3.4",
59-
"@slickgrid-universal/rxjs-observable": "~5.3.4",
53+
"@slickgrid-universal/common": "~5.4.0",
54+
"@slickgrid-universal/custom-footer-component": "~5.4.0",
55+
"@slickgrid-universal/empty-warning-component": "~5.4.0",
56+
"@slickgrid-universal/event-pub-sub": "~5.4.0",
57+
"@slickgrid-universal/pagination-component": "~5.4.0",
58+
"@slickgrid-universal/row-detail-view-plugin": "~5.4.0",
59+
"@slickgrid-universal/rxjs-observable": "~5.4.0",
6060
"dequal": "^2.0.3",
6161
"rxjs": "^7.8.1"
6262
},
@@ -86,12 +86,12 @@
8686
"@ngx-translate/http-loader": "^8.0.0",
8787
"@popperjs/core": "^2.11.8",
8888
"@release-it/conventional-changelog": "^8.0.1",
89-
"@slickgrid-universal/composite-editor-component": "~5.3.4",
90-
"@slickgrid-universal/custom-tooltip-plugin": "~5.3.4",
91-
"@slickgrid-universal/excel-export": "~5.3.4",
92-
"@slickgrid-universal/graphql": "~5.3.4",
93-
"@slickgrid-universal/odata": "~5.3.4",
94-
"@slickgrid-universal/text-export": "~5.3.4",
89+
"@slickgrid-universal/composite-editor-component": "~5.4.0",
90+
"@slickgrid-universal/custom-tooltip-plugin": "~5.4.0",
91+
"@slickgrid-universal/excel-export": "~5.4.0",
92+
"@slickgrid-universal/graphql": "~5.4.0",
93+
"@slickgrid-universal/odata": "~5.4.0",
94+
"@slickgrid-universal/text-export": "~5.4.0",
9595
"@types/dompurify": "^3.0.5",
9696
"@types/fnando__sparkline": "^0.3.7",
9797
"@types/jest": "^29.5.12",

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,13 +218,13 @@ export class GridGraphqlComponent implements OnInit, OnDestroy {
218218
field: 'userId',
219219
value: 123
220220
}],
221-
filterQueryOverride: ({ fieldName, columnDef, columnFilterOperator, searchValue }) => {
221+
filterQueryOverride: ({ fieldName, columnDef, columnFilterOperator, searchValues }) => {
222222
if (columnFilterOperator === OperatorType.custom && columnDef?.id === 'name') {
223223
// technically speaking GraphQL isn't a database query language like SQL, it's an application query language.
224224
// What that means is that GraphQL won't let you write arbitrary queries out of the box.
225225
// It will only support the types of queries defined in your GraphQL schema.
226226
// see this SO: https://stackoverflow.com/a/37981802/1212166
227-
return { field: fieldName, operator: 'Like', value: searchValue };
227+
return { field: fieldName, operator: 'Like', value: searchValues[0] };
228228
}
229229
return;
230230
},

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ export class GridOdataComponent implements OnInit {
137137
enableCount: this.isCountEnabled, // add the count in the OData query, which will return a property named "__count" (v2) or "@odata.count" (v4)
138138
enableSelect: this.isSelectEnabled,
139139
enableExpand: this.isExpandEnabled,
140-
filterQueryOverride: ({ fieldName, columnDef, columnFilterOperator, searchValue }) => {
140+
filterQueryOverride: ({ fieldName, columnDef, columnFilterOperator, searchValues }) => {
141141
if (columnFilterOperator === OperatorType.custom && columnDef?.id === 'name') {
142-
let matchesSearch = (searchValue as string).replace(/\*/g, '.*');
142+
let matchesSearch = searchValues[0].replace(/\*/g, '.*');
143143
matchesSearch = matchesSearch.slice(0, 1) + CARET_HTML_ESCAPED + matchesSearch.slice(1);
144144
matchesSearch = matchesSearch.slice(0, -1) + '$\'';
145145

0 commit comments

Comments
 (0)