Skip to content

Commit

Permalink
feat: add params.editorOptions to change Flatpickr Editor date form…
Browse files Browse the repository at this point in the history
…at (#1048)
  • Loading branch information
ghiscoding committed Aug 15, 2024
1 parent e110817 commit 8b46763
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/models/column.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ export interface Column<TData = any> {
/** column offset width */
offsetWidth?: number;

/** extra custom generic parameters that could be used by your Formatter/Editor or anything else */
params?: any | any[];

/** column previous width */
previousWidth?: number;

Expand Down
5 changes: 3 additions & 2 deletions src/slick.editors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,13 @@ export class FlatpickrEditor<TData = any, C extends Column<TData> = Column<TData
this.input = Utils.createDomElement('input', { type: 'text', className: 'editor-text' }, this.args.container);
this.input.focus();
this.input.select();
const editorOptions = this.args.column.params?.editorOptions; // i.e.: { id: 'start', params: { editorOptions: {altFormat: 'd/m/Y', dateFormat: 'd/m/Y'}} }
this.flatpickrInstance = flatpickr(this.input, {
closeOnSelect: true,
allowInput: true,
altInput: true,
altFormat: 'm/d/Y',
dateFormat: 'm/d/Y',
altFormat: editorOptions?.altFormat ?? 'm/d/Y',
dateFormat: editorOptions?.dateFormat ?? 'm/d/Y',
onChange: () => {
// trigger onCompositeEditorChange event when input changes and it's a Composite Editor
if (this.args.compositeEditorOptions) {
Expand Down

0 comments on commit 8b46763

Please sign in to comment.