Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(common): add global defaultEditorOptions & defaultFilterOptions #1470

Merged
merged 2 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/TOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

* [Cell Menu (Action Menu)](column-functionalities/Cell-Menu.md)
* [Editors](column-functionalities/Editors.md)
* [AutoComplete (jQueryUI)](column-functionalities/editors/AutoComplete-Editor.md)
* [new Autocomplete (Kraaden-lib)](column-functionalities/editors/Autocomplete-Editor-(Kraaden-lib).md)
* [Date Picker (flatpickr)](column-functionalities/editors/Date-Editor-(flatpickr).md)
* [LongText (textarea)](column-functionalities/editors/LongText-Editor-(textarea).md)
Expand Down
28 changes: 28 additions & 0 deletions docs/column-functionalities/Editors.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- [onClick Action Editor (icon click)](#onclick-action-editor-icon-click)
- [AutoComplete Editor](editors/AutoComplete-Editor.md)
- [Select (single/multi) Editors](editors/Select-Dropdown-Editor-(single,multiple).md)
- [Editor Options](#editor-options)
- [Validators](#validators)
- [Custom Validator](#custom-validator)
- [Disabling specific cell Edit](#disabling-specific-cell-edit)
Expand Down Expand Up @@ -192,6 +193,33 @@ export interface OnEventArgs {
}
```

## Editor Options

#### Column Editor `editorOptions`
Some of the Editors could receive extra options, which is mostly the case for Editors using external dependencies (e.g. `autocompleter`, `date`, `multipleSelect`, ...) you can provide options via the `editorOptions`, for example

```ts
this.columnDefinitions = [{
id: 'start', name: 'Start Date', field: 'start',
editor: {
model: Editors.date,
editorOptions: { minDate: 'today' }
}
}];
```

#### Grid Option `defaultEditorOptions
You could also define certain options as a global level (for the entire grid or even all grids) by taking advantage of the `defaultEditorOptions` Grid Option. Note that they are set via the editor type as a key name (`autocompleter`, `date`, ...) and then the content is the same as `editorOptions` (also note that each key is already typed with the correct editor option interface), for example

```ts
this.gridOptions = {
defaultEditorOptions: {
autocompleter: { debounceWaitMs: 150 }, // typed as AutocompleterOption
date: { minDate: 'today' },
longText: { cols: 50, rows: 5 }
}
}
```

## Validators
Each Editor needs to implement the `validate()` method which will be executed and validated before calling the `save()` method. Most Editor will simply validate that the value passed is correctly formed. The Float Editor is one of the more complex one and will first check if the number is a valid float then also check if `minValue` or `maxValue` was passed and if so validate against them. If any errors is found it will return an object of type `EditorValidatorOutput` (see the signature on top).
Expand Down
Loading
Loading