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

Commit 0fa6591

Browse files
committed
Merge branch 'master' into bugfix/dark-mode-grid-menu
2 parents 7f166b2 + 446728b commit 0fa6591

File tree

12 files changed

+840
-547
lines changed

12 files changed

+840
-547
lines changed

docs/column-functionalities/filters/custom-filter.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ You can also create your own Custom Filter with any html/css you want and/or jQu
1616
#### Limitations
1717
- as mentioned in the description, only html/css and/or jQuery libraries are supported.
1818
- this mainly mean that Angular templates (components) are not supported (feel free to contribute).
19-
- SlickGrid uses `table-cell` as CSS for it to display a consistent height for each rows (this keeps the same row height/line-height to always be the same).
19+
- SlickGrid uses `table-cell` as CSS for it to display a consistent height for each rows (this keeps the same row height/line-height to always be the same).
2020
- all this to say that you might be in a situation were your filter shows in the back of the grid. The best approach to overcome this is to use a modal if you can or if the library support `append to body container`. For example, you can see that `multiple-select-vanilla` supports a `container`
2121

2222
### How to use Custom Filter?
23-
1. You first need to create a `class` using the [Filter interface](https://github.com/ghiscoding/slickgrid-universal/blob/master/packages/common/src/interfaces/filter.interface.ts). Make sure to create all necessary public properties and functions.
23+
1. You first need to create a `class` using the [Filter interface](https://github.com/ghiscoding/slickgrid-universal/blob/master/packages/common/src/interfaces/filter.interface.ts). Make sure to create all necessary public properties and functions.
2424
- You can see a demo with a [custom-inputFilter.ts](https://github.com/ghiscoding/angular-slickgrid/blob/master/src/app/examples/custom-inputFilter.ts) that is used in the [demo - example 4](https://ghiscoding.github.io/Angular-Slickgrid/#/clientside)
25-
2. Simply set the `columnDefinition.filter.model` to your new custom Filter class and instantiate it with `new` (you can also use dependency injection in the constructor if you wish). Here is an example with a custom input filter:
26-
```typescript
25+
2. Simply set the `columnDefinition.filter.model` to your new custom Filter class and instantiate it with `new` (you can also use dependency injection in the constructor if you wish). Here is an example with a custom input filter:
26+
```typescript
2727
// define you columns, in this demo Effort Driven will use a Select Filter
28-
this.columnDefinitions = [
28+
this.columnDefinitions = [
2929
{ id: 'title', name: 'Title', field: 'title' },
3030
{ id: 'description', name: 'Description', field: 'description', type: FieldType.string,
31-
filterable: true,
31+
filterable: true,
3232
filter: {
33-
model: new CustomInputFilter() // create a new instance to make each Filter independent from each other
33+
model: CustomInputFilter // create a new instance to make each Filter independent from each other
3434
}
3535
}
3636
];
@@ -47,7 +47,7 @@ If you want to load the grid with certain default filter(s), you can use the fol
4747

4848
For example, setting a default value into an `input` element, you can simply get the search term with `columnDef.filter.searchTerms` and set the default value in jquery with `$(filterElm).val(this.searchTerms);`
4949

50-
### Collection
50+
### Collection
5151
If you want to pass a `collection` to your filter (for example, a multiple-select needs a select list of options), you can then use it in your custom filter through `columnDef.filter.collection`
5252

5353
#### `key/label` pair
@@ -61,7 +61,7 @@ this.columnDef.filter.collection.forEach((option: SelectOption) => {
6161
```
6262

6363
#### Custom Structure (key/label pair)
64-
What if your `collection` have totally different value/label pair? In this case, you can use the `customStructure` to change the property name(s) to use. You can change the label and/or the value, they can be passed independently.
64+
What if your `collection` have totally different value/label pair? In this case, you can use the `customStructure` to change the property name(s) to use. You can change the label and/or the value, they can be passed independently.
6565
For example:
6666
```typescript
6767
// use custom structure value/label pair
@@ -80,7 +80,7 @@ this.columnDef.filter.collection.forEach((option: SelectOption) => {
8080
By default a `collection` uses the `label/value` pair without translation or `labelKey/value` pair with translation usage. So if you want to use translations, then you can loop through your `collection` and use the `labelKey/value` properties. For example:
8181
```typescript
8282
this.columnDef.filter.collection.forEach((option: SelectOption) => {
83-
// translate label
83+
// translate label
8484
const textLabel = (option.labelKey && typeof this.i18n.tr === 'function') ? this.i18n.tr(option.labelKey || ' ') : option.labelKey;
8585

8686
// use the option value & translated label
@@ -98,7 +98,7 @@ const labelName = (this.columnDef.filter.customStructure) ? this.columnDef.filte
9898
const valueName = (this.columnDef.filter.customStructure) ? this.columnDef.filter.customStructure.value : 'value';
9999

100100
this.columnDef.filter.collection.forEach((option: SelectOption) => {
101-
// translate label
101+
// translate label
102102
const textLabel = (option.labelKey && typeof this.i18n.tr === 'function') ? this.i18n.tr(option[labelName] || ' ') : option[labelName];
103103

104104
// use the option value & translated label
@@ -109,7 +109,7 @@ this.columnDef.filter.collection.forEach((option: SelectOption) => {
109109
## Custom Filter with Angular Components
110110
You can see them in [Example 22](https://ghiscoding.github.io/Angular-Slickgrid/#/angular-components) which have both Custom Editors & Filters which uses Angular Components. The 2nd column "Assignee" is the column that uses both (it uses `ng-select` 3rd party lib wrapped in an Angular Components [here](https://github.com/ghiscoding/angular-slickgrid/blob/master/src/app/examples/filter-ng-select.component.ts)) and you need to create a Custom Filter like [here](https://github.com/ghiscoding/angular-slickgrid/blob/master/src/app/examples/custom-angularComponentFilter.ts) and use that Custom Filter in your column definition like [here](https://github.com/ghiscoding/angular-slickgrid/blob/master/src/app/examples/grid-angular.component.ts#L109).
111111

112-
Personally I don't find this very straightforward and I don't recommend using Angular Components for Editors/Filters as it adds a lot of boilerplate (compare to 1 step with a jQuery Custom Filter) but if you really wish to go that route, it's now possible following the steps shown below.
112+
Personally I don't find this very straightforward and I don't recommend using Angular Components for Editors/Filters as it adds a lot of boilerplate (compare to 1 step with a jQuery Custom Filter) but if you really wish to go that route, it's now possible following the steps shown below.
113113

114114
The steps to use an Angular Component as a Custom Filter are the following:
115115
1. Create a Custom Filter that will handle the creation or compilation of the Angular Component into a SlickGrid Editors. For that you can take a look at this [Custom Filter](https://github.com/ghiscoding/angular-slickgrid/blob/master/src/app/examples/custom-angularComponentFilter.ts)

docs/grid-functionalities/Grid-State-&-Preset.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ export interface GridState {
9191
pageNumber: number;
9292
pageSize: number;
9393
};
94+
pinning?: CurrentPinning;
95+
rowSelection?: CurrentRowSelection | null;
96+
treeData?: Partial<TreeToggleStateChange> | null;
9497
}
9598
```
9699

@@ -199,21 +202,18 @@ export class ExampleComponent implements OnInit, OnDestroy {
199202
```
200203

201204
## How to Load Grid with certain Columns Preset (example hide certain Column(s) on load)
202-
You can show/hide or even change column position all via the `presets`, yes `presets` is that powerful. All you need is to pass all Columns that you want to show as part of the `columns` property of `presets`. Typically you already have the entire columns definition since you just defined it, so you can re-use that and just use `map` to loop through and populate the `columns` according to the structure needed (see [preset structure](#structure)). What you have to know is that whatever array you pass will drive what the user will see and at which order the columns will show (basically the array order does matter). If a Columns is omitted from that array, then it will become a hidden column (you can still show it through Grid Menu or Column Picker).
205+
You can show/hide or even change a column position via the `presets`, yes `presets` is that powerful. All you need to do is to pass all Columns that you want to show as part of the `columns` property of `presets`. Typically you already have the entire columns definition since you just defined it, so you can loop through it and just use `map` to list the `columns` according to the structure needed (see [preset structure](Grid-State-&-Preset#structure.md)). What you have to know is that whatever array you provide to `presets`, that will equal to what the user will see and also in which order the columns will show (the array order does matter in this case). If a Columns is omitted from that array, then it will be considered to be a hidden column (you can still show it through Grid Menu and/or Column Picker).
203206

204207
So let say that we want to hide the last Column on page load, we can just find the column by it's `id` that you want to hide and pass the new column definition to the `presets` (again make sure to follow the correct preset structure).
205208

206-
##### Component
207209
```ts
208210
this.columnDefinitions = [
209-
// your definition
211+
// initial column definitions
210212
];
211213
212-
// for example, let's hide last column, we can just use `pop()` last column
213-
// and use `map()` to only pull required field for presets to work
214-
const mappedColumnDefinitions = this.columnDefinitions.map((col) => {
215-
return { columnId: col.id, width: col.width };
216-
});
214+
// for example, let's hide last column, we can just use `pop()` to ommit last column
215+
// and use `map()` to pull only the required field for presets to work
216+
const mappedColumnDefinitions = this.columnDefinitions.map(col => ({ columnId: col.id, width: col.width }));
217217
mappedColumnDefinitions.pop();
218218

219219
// then pass it to the presets
@@ -225,7 +225,8 @@ this.gridOptions = {
225225
```
226226
This would be the easiest way to do it.
227227
228-
As pointed out earlier, the `presets` requires a specific structure where the `columns` is the list of columns to show/hide with their possible widths and also the position in the array is very important as it defines the position shown in the UI
228+
As pointed out earlier, the `presets` requires a specific structure where the `columns` is the list of columns to show/hide with their possible widths. Also worth mentioning again that the position in the array is very important as it defines the position shown in the UI.
229+
229230
```ts
230231
this.gridOptions = {
231232
enableFiltering: true,

docs/migrations/Migration-to-2.x.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@ this.columnDefinitions = [
239239
id: 'description', name: 'Description', field: 'description',
240240
filter: {
241241
- type: FilterType.custom,
242-
- customFilter: new CustomInputFilter()
243-
+ model: new CustomInputFilter() // create a new instance to make each Filter independent from each other
242+
- customFilter: CustomInputFilter
243+
+ model: CustomInputFilter // create a new instance to make each Filter independent from each other
244244
}
245245
},
246246
{

package.json

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -64,23 +64,23 @@
6464
},
6565
"devDependencies": {
6666
"@4tw/cypress-drag-drop": "^2.2.5",
67-
"@angular-devkit/build-angular": "^17.2.2",
68-
"@angular-eslint/builder": "^17.2.1",
69-
"@angular-eslint/eslint-plugin": "^17.2.1",
70-
"@angular-eslint/eslint-plugin-template": "^17.2.1",
71-
"@angular-eslint/schematics": "^17.2.1",
72-
"@angular-eslint/template-parser": "^17.2.1",
73-
"@angular/animations": "^17.2.3",
74-
"@angular/cli": "^17.2.2",
75-
"@angular/common": "^17.2.3",
76-
"@angular/compiler": "^17.2.3",
77-
"@angular/compiler-cli": "^17.2.3",
78-
"@angular/core": "^17.2.3",
79-
"@angular/forms": "^17.2.3",
80-
"@angular/language-service": "^17.2.3",
81-
"@angular/platform-browser": "^17.2.3",
82-
"@angular/platform-browser-dynamic": "^17.2.3",
83-
"@angular/router": "^17.2.3",
67+
"@angular-devkit/build-angular": "^17.3.0",
68+
"@angular-eslint/builder": "^17.3.0",
69+
"@angular-eslint/eslint-plugin": "^17.3.0",
70+
"@angular-eslint/eslint-plugin-template": "^17.3.0",
71+
"@angular-eslint/schematics": "^17.3.0",
72+
"@angular-eslint/template-parser": "^17.3.0",
73+
"@angular/animations": "^17.3.0",
74+
"@angular/cli": "^17.3.0",
75+
"@angular/common": "^17.3.0",
76+
"@angular/compiler": "^17.3.0",
77+
"@angular/compiler-cli": "^17.3.0",
78+
"@angular/core": "^17.3.0",
79+
"@angular/forms": "^17.3.0",
80+
"@angular/language-service": "^17.3.0",
81+
"@angular/platform-browser": "^17.3.0",
82+
"@angular/platform-browser-dynamic": "^17.3.0",
83+
"@angular/router": "^17.3.0",
8484
"@faker-js/faker": "^8.4.1",
8585
"@fnando/sparkline": "^0.3.10",
8686
"@ng-select/ng-select": "^12.0.7",
@@ -97,28 +97,28 @@
9797
"@types/flatpickr": "^3.1.2",
9898
"@types/fnando__sparkline": "^0.3.7",
9999
"@types/jest": "^29.5.12",
100-
"@types/node": "^20.11.24",
100+
"@types/node": "^20.11.28",
101101
"@types/sortablejs": "^1.15.8",
102-
"@typescript-eslint/eslint-plugin": "^7.1.1",
103-
"@typescript-eslint/parser": "^7.1.1",
102+
"@typescript-eslint/eslint-plugin": "^7.3.0",
103+
"@typescript-eslint/parser": "^7.3.0",
104104
"bootstrap": "^5.3.3",
105105
"copyfiles": "^2.4.1",
106106
"custom-event-polyfill": "^1.0.7",
107-
"cypress": "^13.6.6",
107+
"cypress": "^13.7.0",
108108
"eslint": "^8.57.0",
109109
"fetch-jsonp": "^1.3.0",
110110
"font-awesome": "^4.7.0",
111111
"jest": "^29.7.0",
112112
"jest-extended": "^4.0.2",
113113
"jest-preset-angular": "^14.0.3",
114114
"moment-mini": "^2.29.4",
115-
"ng-packagr": "^17.2.1",
115+
"ng-packagr": "^17.3.0",
116116
"ngx-bootstrap": "^12.0.0",
117117
"npm-run-all2": "^6.1.2",
118118
"release-it": "^17.1.1",
119119
"rimraf": "^5.0.5",
120120
"rxjs": "^7.8.1",
121-
"sass": "^1.71.1",
121+
"sass": "^1.72.0",
122122
"servor": "^4.0.2",
123123
"stream-browserify": "^3.0.0",
124124
"ts-node": "^10.9.2",
@@ -131,7 +131,7 @@
131131
"npm": ">=6.14.13"
132132
},
133133
"resolutions": {
134-
"caniuse-lite": "1.0.30001591",
134+
"caniuse-lite": "1.0.30001599",
135135
"semver": "^7.6.0"
136136
}
137137
}

src/app/examples/custom-angularComponentEditor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ export class CustomAngularComponentEditor implements Editor {
7777
init() {
7878
if (!this.columnEditor || !this.columnEditor.params.component || !(this.angularUtilService instanceof AngularUtilService)) {
7979
throw new Error(`[Angular-Slickgrid] For Editor with Angular Component to work properly, you need to provide the "AngularUtilService" via the Editor "params" OR the Grid Options "params"
80-
Example: this.columnDefs = [{ id: 'title', field: 'title', editor: { model: CustomAngularComponentEditor, collection: [...], params: { component: MyComponent, angularUtilService: this.angularUtilService }}];
81-
OR this.columnDefs = [{ id: 'title', field: 'title', editor: { model: CustomAngularComponentEditor, collection: [...] }]; this.gridOptions = { params: { angularUtilService: this.angularUtilService }}`);
80+
Example: this.columnDefs = [{ id: 'title', field: 'title', editor: { model: CustomEditor, collection: [...], params: { component: MyComponent, angularUtilService: this.angularUtilService }}];
81+
OR this.columnDefs = [{ id: 'title', field: 'title', editor: { model: CustomEditor, collection: [...] }]; this.gridOptions = { params: { angularUtilService: this.angularUtilService }}`);
8282
}
8383
if (this.columnEditor?.params.component) {
8484
const componentOutput = this.angularUtilService.createAngularComponentAppendToDom(this.columnEditor.params.component, this.args.container);

src/app/examples/custom-angularComponentFilter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ export class CustomAngularComponentFilter implements Filter {
6363

6464
if (!this.columnFilter || !this.columnFilter.params.component || !(this.angularUtilService instanceof AngularUtilService)) {
6565
throw new Error(`[Angular-Slickgrid] For Filter with Angular Component to work properly, you need to provide the "AngularUtilService" via the Filter "params" OR the Grid Options "params"
66-
Example: this.columnDefs = [{ id: 'title', field: 'title', filter: { model: CustomAngularComponentFilter, collection: [...], params: { component: MyComponent, angularUtilService: this.angularUtilService }}];
67-
OR this.columnDefs = [{ id: 'title', field: 'title', filter: { model: CustomAngularComponentFilter, collection: [...] }]; this.gridOptions = { params: { angularUtilService: this.angularUtilService }}`);
66+
Example: this.columnDefs = [{ id: 'title', field: 'title', filter: { model: CustomFilter, collection: [...], params: { component: MyComponent, angularUtilService: this.angularUtilService }}];
67+
OR this.columnDefs = [{ id: 'title', field: 'title', filter: { model: CustomFilter, collection: [...] }]; this.gridOptions = { params: { angularUtilService: this.angularUtilService }}`);
6868
}
6969

7070
if (this.columnFilter?.params.component) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export class GridAngularComponent implements OnInit {
123123
filterable: true,
124124
sortable: true,
125125
filter: {
126-
model: new CustomAngularComponentFilter(), // create a new instance to make each Filter independent from each other
126+
model: CustomAngularComponentFilter, // create a new instance to make each Filter independent from each other
127127
collection: this.assignees,
128128
params: {
129129
component: FilterNgSelectComponent,
@@ -155,7 +155,7 @@ export class GridAngularComponent implements OnInit {
155155
filterable: true,
156156
sortable: true,
157157
filter: {
158-
model: new CustomAngularComponentFilter(), // create a new instance to make each Filter independent from each other
158+
model: CustomAngularComponentFilter, // create a new instance to make each Filter independent from each other
159159
collection: this.assignees,
160160
params: {
161161
component: FilterNgSelectComponent,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export class GridClientSideComponent implements OnInit {
6969
id: 'description', name: 'Description', field: 'description', filterable: true, sortable: true, minWidth: 80,
7070
type: FieldType.string,
7171
filter: {
72-
model: new CustomInputFilter(), // create a new instance to make each Filter independent from each other
72+
model: CustomInputFilter, // create a new instance to make each Filter independent from each other
7373
enableTrimWhiteSpace: true // or use global "enableFilterTrimWhiteSpace" to trim on all Filters
7474
}
7575
},

src/app/examples/grid-draggrouping.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ <h2>
8888
[dataset]="dataset"
8989
[columnDefinitions]="columnDefinitions"
9090
[gridOptions]="gridOptions"
91+
(onCellChange)="onCellChanged()"
9192
(onAngularGridCreated)="angularGridReady($event.detail)">
9293
</angular-slickgrid>
9394
</div>

0 commit comments

Comments
 (0)