Skip to content

Commit

Permalink
feat(common): add global defaultEditorOptions & `defaultFilterOptio…
Browse files Browse the repository at this point in the history
…ns` (#1470)

* feat(common): add global `defaultEditorOptions` & `defaultFilterOptions`
  • Loading branch information
ghiscoding committed Apr 18, 2024
1 parent 0a4d402 commit 0462f17
Show file tree
Hide file tree
Showing 34 changed files with 491 additions and 549 deletions.
1 change: 0 additions & 1 deletion docs/TOC.md
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
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

0 comments on commit 0462f17

Please sign in to comment.