Skip to content

Commit

Permalink
fix: Filter model is now FilterConstructor and shouldn't be newed (
Browse files Browse the repository at this point in the history
…#1169)

- the Filter `model` prop should be a constructor and it shouldn't newed (instantiated), it was defined like so in the docs and Wikis but that was actually wrong
- ref Slickgrid-Universal [PR 1430](ghiscoding/slickgrid-universal#1430)
  • Loading branch information
ghiscoding committed Mar 13, 2024
1 parent ba9d519 commit de97e6c
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/column-functionalities/filters/custom-filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ You can also create your own Custom Filter with any html/css you want and/or jQu
{ id: 'description', name: 'Description', field: 'description', type: FieldType.string,
filterable: true,
filter: {
model: new CustomInputFilter() // create a new instance to make each Filter independent from each other
model: CustomInputFilter // create a new instance to make each Filter independent from each other
}
}
];
Expand Down
4 changes: 2 additions & 2 deletions docs/migrations/migration-to-2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ this.columnDefinitions = [
id: 'description', name: 'Description', field: 'description',
filter: {
- type: FilterType.custom,
- customFilter: new CustomInputFilter()
+ model: new CustomInputFilter() // create a new instance to make each Filter independent from each other
- customFilter: CustomInputFilter
+ model: CustomInputFilter // create a new instance to make each Filter independent from each other
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export class CustomAureliaViewModelEditor implements Editor {
async init() {
if (!this.columnEditor?.params?.viewModel) {
throw new Error(`[Aurelia-Slickgrid] For the Editors.aureliaComponent to work properly, you need to fill in the "templateUrl" property of your Custom Element Editor.
Example: this.columnDefs = [{ id: 'title', field: 'title', editor: { model: new CustomAureliaViewModelFilter(), collection: [...], param: { viewModel: MyVM } },`);
Example: this.columnDefs = [{ id: 'title', field: 'title', editor: { model: CustomEditor, collection: [...], param: { viewModel: MyVM } },`);
}
if (this.columnEditor?.params?.viewModel) {
const bindableData = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class CustomAureliaViewModelFilter implements Filter {

if (!this.columnFilter?.params?.viewModel) {
throw new Error(`[Aurelia-Slickgrid] For the Filters.aureliaComponent to work properly, you need to fill in the "viewModel" property of your Custom Element Filter.
Example: this.columnDefs = [{ id: 'title', field: 'title', filter: { model: new CustomAureliaViewModelFilter(), collection: [...], param: { viewModel: MyVM } },`);
Example: this.columnDefs = [{ id: 'title', field: 'title', filter: { model: CustomFilter, collection: [...], param: { viewModel: MyVM } },`);
}

if (this.columnFilter.params.viewModel) {
Expand Down
2 changes: 1 addition & 1 deletion packages/demo/src/examples/slickgrid/example23.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class Example23 {
id: 'description', name: 'Description', field: 'description', filterable: true, sortable: true, minWidth: 80,
type: FieldType.string,
filter: {
model: new CustomInputFilter(), // create a new instance to make each Filter independent from each other
model: CustomInputFilter, // create a new instance to make each Filter independent from each other
enableTrimWhiteSpace: true // or use global "enableFilterTrimWhiteSpace" to trim on all Filters
}
},
Expand Down
4 changes: 2 additions & 2 deletions packages/demo/src/examples/slickgrid/example26.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class Example26 {
filterable: true,
sortable: true,
filter: {
model: new CustomAureliaViewModelFilter(),
model: CustomAureliaViewModelFilter,
collection: this.assignees,
params: {
viewModel: FilterSelect
Expand Down Expand Up @@ -132,7 +132,7 @@ export class Example26 {
filterable: true,
sortable: true,
filter: {
model: new CustomAureliaViewModelFilter(),
model: CustomAureliaViewModelFilter,
collection: this.assignees,
params: {
viewModel: FilterSelect
Expand Down
2 changes: 1 addition & 1 deletion packages/demo/src/examples/slickgrid/example4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class Example4 {
id: 'description', name: 'Description', field: 'description', filterable: true, sortable: true, minWidth: 80,
type: FieldType.string,
filter: {
model: new CustomInputFilter(), // create a new instance to make each Filter independent from each other customFilter
model: CustomInputFilter, // create a new instance to make each Filter independent from each other customFilter
enableTrimWhiteSpace: true
}
},
Expand Down

0 comments on commit de97e6c

Please sign in to comment.