Skip to content

@serenity-is/corelib / ColumnPickerDialog

Class: ColumnPickerDialog<P>

Defined in: src/ui/datagrid/columnpickerdialog.tsx:54

Dialog that lets users show/hide, reorder, and pin grid columns.

Extends

Type Parameters

P

P extends ColumnPickerDialogOptions = ColumnPickerDialogOptions

Options type for the dialog.

Constructors

Constructor

new ColumnPickerDialog<P>(opt): ColumnPickerDialog<P>

Defined in: src/ui/datagrid/columnpickerdialog.tsx:73

Creates a column picker dialog.

Parameters

opt

P

Options for the dialog.

Returns

ColumnPickerDialog<P>

Overrides

BaseDialog.constructor

Properties

dialog

protected dialog: Dialog

Defined in: src/ui/dialogs/basedialog.tsx:27

Inherited from

BaseDialog.dialog


domNode

readonly domNode: HTMLElement

Defined in: src/ui/widgets/widget.ts:98

The DOM node this widget is bound to.

Inherited from

BaseDialog.domNode


idPrefix

readonly idPrefix: string

Defined in: src/ui/widgets/widget.ts:96

The id prefix used for this widget's child element ids.

Inherited from

BaseDialog.idPrefix


onAfterInit

readonly onAfterInit: PubSub<DialogEvent>

Defined in: src/ui/dialogs/basedialog.tsx:35

Raised after this dialog is initialized.

Inherited from

BaseDialog.onAfterInit


options

protected readonly options: WidgetProps<P>

Defined in: src/ui/widgets/widget.ts:92

The widget's options/props.

Inherited from

BaseDialog.options


tabs

protected tabs: Fluent<HTMLElement>

Defined in: src/ui/dialogs/basedialog.tsx:24

Inherited from

BaseDialog.tabs


toolbar

protected toolbar: Toolbar

Defined in: src/ui/dialogs/basedialog.tsx:25

Inherited from

BaseDialog.toolbar


uniqueName

readonly uniqueName: string

Defined in: src/ui/widgets/widget.ts:94

A unique name for this widget instance, used for event namespacing.

Inherited from

BaseDialog.uniqueName


validator

protected validator: any

Defined in: src/ui/dialogs/basedialog.tsx:26

Inherited from

BaseDialog.validator


[typeInfo]

static [typeInfo]: ClassTypeInfo<"Serenity.">

Defined in: src/ui/datagrid/columnpickerdialog.tsx:56

Overrides

BaseDialog.[typeInfo]


defaultDeferInit

static defaultDeferInit: boolean = false

Defined in: src/ui/widgets/widget.ts:106

Whether the classes that neither have a DeferInitAttribute (see Attributes.deferInit) nor override deferredInit, nor have a base class that says true or false, defer their initialization; false by default. An application whose widgets are written for deferred initialization turns it on in its script init, before any widget is created.

Inherited from

BaseDialog.defaultDeferInit


isComponent

readonly static isComponent: true = true

Defined in: src/ui/widgets/widget.ts:530

Inherited from

BaseDialog.isComponent


onAfterInit

readonly static onAfterInit: PubSub<DialogEvent>

Defined in: src/ui/dialogs/basedialog.tsx:33

Static event raised after any dialog is initialized, e.g. when the form, the tabs and the toolbar of an entity dialog are there, for a feature that adds a tab or a button to some dialogs, e.g. a help or an assistant.

Inherited from

BaseDialog.onAfterInit

Accessors

dialogTitle

Get Signature

get dialogTitle(): string

Defined in: src/ui/dialogs/basedialog.tsx:364

Returns the current dialog title.

Returns

string

The dialog title.

Set Signature

set dialogTitle(value): void

Defined in: src/ui/dialogs/basedialog.tsx:369

Sets the dialog title.

Parameters
value

string

Returns

void

Inherited from

BaseDialog.dialogTitle


element

Get Signature

get element(): Fluent

Defined in: src/ui/widgets/widget.ts:216

Returns a Fluent(this.domNode) object

Returns

Fluent

Inherited from

BaseDialog.element


initialized

Get Signature

get protected initialized(): boolean

Defined in: src/ui/widgets/widget.ts:137

Whether the widget is initialized: always for one that initializes in its constructor, and for one that defers its initialization (see isDeferredInit), once its deferredInit is done.

Returns

boolean

Inherited from

BaseDialog.initialized


props

Get Signature

get props(): WidgetProps<P>

Defined in: src/ui/widgets/widget.ts:503

Returns the widget's props/options.

Returns

WidgetProps<P>

Inherited from

BaseDialog.props


usesDeferredInit

Get Signature

get protected usesDeferredInit(): boolean

Defined in: src/ui/widgets/widget.ts:129

Whether this widget defers its initialization, see isDeferredInit.

Returns

boolean

Inherited from

BaseDialog.usesDeferredInit

Methods

addCssClass()

protected addCssClass(): void

Defined in: src/ui/dialogs/basedialog.tsx:124

Hook for subclasses to add CSS classes; the class goes to the dialog/modal/panel element.

Returns

void

Inherited from

BaseDialog.addCssClass


addValidationRule()

Call Signature

addValidationRule(rule, uniqueName?): void

Defined in: src/ui/widgets/widget.ts:267

Adds a validation rule to the widget's DOM node.

Parameters
rule

(input) => string

The validation rule function, or a unique name when the two-argument overload is used.

uniqueName?

string

A unique name for the rule, or the rule function when the two-argument overload is used.

Returns

void

Inherited from

BaseDialog.addValidationRule

Call Signature

addValidationRule(uniqueName, rule): void

Defined in: src/ui/widgets/widget.ts:268

Adds a validation rule to the widget's DOM node.

Parameters
uniqueName

string

A unique name for the rule, or the rule function when the two-argument overload is used.

rule

(input) => string

The validation rule function, or a unique name when the two-argument overload is used.

Returns

void

Inherited from

BaseDialog.addValidationRule


afterRender()

protected afterRender(callback): void

Defined in: src/ui/widgets/widget.ts:359

Queues a callback to run after the widget's contents are rendered.

Parameters

callback

() => void

The callback to run after rendering.

Returns

void

Inherited from

BaseDialog.afterRender


arrange()

arrange(): void

Defined in: src/ui/dialogs/basedialog.tsx:321

Triggers layout on all elements that require it.

Returns

void

Inherited from

BaseDialog.arrange


byId()

protected byId<TElement>(id): Fluent<TElement>

Defined in: src/ui/widgets/widget.ts:279

Finds a child element by its prefix-relative id.

Type Parameters

TElement

TElement extends HTMLElement = HTMLElement

Parameters

id

string

The id relative to the widget's id prefix.

Returns

Fluent<TElement>

A Fluent wrapper for the matching element.

Inherited from

BaseDialog.byId


canResetAllSettings()

protected canResetAllSettings(): boolean

Defined in: src/ui/datagrid/columnpickerdialog.tsx:284

Whether the grid of the picker can reset all its settings, see DataGrid.resetSettings.

Returns

boolean


change()

change(handler): void

Defined in: src/ui/widgets/widget.ts:310

Registers a change handler on the widget's DOM node.

Parameters

handler

(e) => void

The change event handler.

Returns

void

Inherited from

BaseDialog.change


changeSelect2()

changeSelect2(handler): void

Defined in: src/ui/widgets/widget.ts:319

Registers a change handler that ignores changes originating from combobox setting values.

Parameters

handler

(e) => void

The change event handler.

Returns

void

Inherited from

BaseDialog.changeSelect2


createColumnItems()

protected createColumnItems(): void

Defined in: src/ui/datagrid/columnpickerdialog.tsx:511

Creates the list items for all columns.

Returns

void


createSearch()

protected createSearch(div): void

Defined in: src/ui/datagrid/columnpickerdialog.tsx:262

Creates the quick search input in the dialog.

Parameters

div

HTMLElement

Container element for the search bar.

Returns

void


deferredInit()

protected deferredInit(): void | PromiseLike<void>

Defined in: src/ui/dialogs/basedialog.tsx:65

Initializes a dialog that defers its initialization (see Widget.isDeferredInit): its contents, and then what the constructor does for the others.

Returns

void | PromiseLike<void>

Inherited from

BaseDialog.deferredInit


destroy()

destroy(): void

Defined in: src/ui/datagrid/columnpickerdialog.tsx:156

Cleans up handlers and delegates to the base destroy.

Returns

void

Overrides

BaseDialog.destroy


dialogClose()

dialogClose(result?): void

Defined in: src/ui/dialogs/basedialog.tsx:356

Closes the dialog with the given result.

Parameters

result?

string

The close result.

Returns

void

Inherited from

BaseDialog.dialogClose


dialogOpen()

dialogOpen(asPanel?): void

Defined in: src/ui/dialogs/basedialog.tsx:209

Opens the dialog, optionally as a panel.

Parameters

asPanel?

boolean

When true, opens as a panel instead of a modal dialog.

Returns

void

Inherited from

BaseDialog.dialogOpen


findById()

protected findById<TElement>(id): TElement

Defined in: src/ui/widgets/widget.ts:291

Finds a child element by its prefix-relative id.

Type Parameters

TElement

TElement extends HTMLElement = HTMLElement

Parameters

id

string

The id relative to the widget's id prefix.

Returns

TElement

The matching element, or null if not found.

Inherited from

BaseDialog.findById


getCssClass()

protected getCssClass(): string

Defined in: src/ui/widgets/widget.ts:231

Returns the CSS class(es) applied to the widget's DOM node.

Returns

string

The space-separated CSS class string.

Inherited from

BaseDialog.getCssClass


getCustomAttribute()

protected getCustomAttribute<TAttr>(attrType, inherit): TAttr

Defined in: src/ui/widgets/widget.ts:351

Returns a custom attribute applied to the widget's type.

Type Parameters

TAttr

TAttr extends CustomAttribute

Parameters

attrType

(...args) => TAttr

The attribute type to look up.

inherit

boolean = true

Whether to search inherited types; defaults to true.

Returns

TAttr

The matching attribute, or null.

Inherited from

BaseDialog.getCustomAttribute


getDialogButtons()

protected getDialogButtons(): DialogButton[]

Defined in: src/ui/datagrid/columnpickerdialog.tsx:448

Returns no dialog buttons; the picker uses its own controls.

Returns

DialogButton[]

Null.

Overrides

BaseDialog.getDialogButtons


getDialogOptions()

protected getDialogOptions(): DialogOptions

Defined in: src/ui/datagrid/columnpickerdialog.tsx:437

Returns the dialog options, sized for the column picker.

Returns

DialogOptions

Dialog options.

Overrides

BaseDialog.getDialogOptions


getGridField()

getGridField(): Fluent

Defined in: src/ui/widgets/widget.ts:302

Returns the closest .field element containing the widget's DOM node.

Returns

Fluent

A Fluent wrapper for the grid field.

Inherited from

BaseDialog.getGridField


getInitialDialogTitle()

protected getInitialDialogTitle(): string

Defined in: src/ui/dialogs/basedialog.tsx:132

Returns the initial dialog title.

Returns

string

The initial title text.

Inherited from

BaseDialog.getInitialDialogTitle


getToolbarButtons()

protected getToolbarButtons(): ToolButton[]

Defined in: src/ui/dialogs/basedialog.tsx:266

Returns the toolbar buttons for this dialog.

Returns

ToolButton[]

Tool button definitions.

Inherited from

BaseDialog.getToolbarButtons


getValidatorOptions()

protected getValidatorOptions(): any

Defined in: src/ui/dialogs/basedialog.tsx:288

Returns the validator options for the form.

Returns

any

Validator options.

Inherited from

BaseDialog.getValidatorOptions


handleResetAllSettings()

protected handleResetAllSettings(e): void

Defined in: src/ui/datagrid/columnpickerdialog.tsx:292

Resets all the settings of the grid, not only its columns, after a confirmation, and closes the picker, see DataGrid.resetSettings.

Parameters

e

Event

Returns

void


handleResponsive()

protected handleResponsive(): void

Defined in: src/ui/dialogs/basedialog.tsx:387

Handles responsive layout for the dialog.

Returns

void

Inherited from

BaseDialog.handleResponsive


handleRestoreDefaults()

protected handleRestoreDefaults(): void

Defined in: src/ui/datagrid/columnpickerdialog.tsx:304

Restores the default column order and visibility.

Returns

void


handleSearch()

protected handleSearch(args): void

Defined in: src/ui/datagrid/columnpickerdialog.tsx:381

Filters the column list based on the search query.

Parameters

args

QuickSearchArgs

Quick search arguments.

Returns

void


handleToggleAllClick()

protected handleToggleAllClick(): void

Defined in: src/ui/datagrid/columnpickerdialog.tsx:351

Handles clicks on the toggle-all checkbox.

Returns

void


handleToggleClick()

protected handleToggleClick(e): void

Defined in: src/ui/datagrid/columnpickerdialog.tsx:197

Handles clicks on a column's visibility toggle.

Parameters

e

MouseEvent

Mouse event.

Returns

void


init()

init(): this

Defined in: src/ui/widgets/widget.ts:375

Initializes the widget: one that defers its initialization (see isDeferredInit) starts it, and it may end later, see initAsync; others are initialized by their constructors already.

Returns

this

This widget instance.

Inherited from

BaseDialog.init


initAsync()

initAsync(): Promise<ColumnPickerDialog<P>>

Defined in: src/ui/widgets/widget.ts:388

Initializes the widget once and waits until it is initialized: one that defers its initialization (see isDeferredInit) runs its deferredInit, the first time it is called; others are initialized by their constructors.

Returns

Promise<ColumnPickerDialog<P>>

A promise of this widget, which is rejected when its initialization fails.

Inherited from

BaseDialog.initAsync


initDialog()

protected initDialog(): void

Defined in: src/ui/dialogs/basedialog.tsx:179

Initializes the underlying dialog element.

Returns

void

Inherited from

BaseDialog.initDialog


initNow()

protected initNow(): boolean

Defined in: src/ui/widgets/widget.ts:146

Starts the initialization of a widget that defers it, if it hasn't started, and tells whether it is initialized now, e.g. as it had nothing to wait for. A method that needs the widget initialized waits for initAsync when it is not, e.g. if (!this.initNow()) return void this.initAsync().then(...).

Returns

boolean

Inherited from

BaseDialog.initNow


initTabs()

protected initTabs(): void

Defined in: src/ui/dialogs/basedialog.tsx:377

Initializes the tabs from the Tabs element.

Returns

void

Inherited from

BaseDialog.initTabs


initToolbar()

protected initToolbar(): void

Defined in: src/ui/dialogs/basedialog.tsx:273

Initializes the toolbar from the Toolbar element.

Returns

void

Inherited from

BaseDialog.initToolbar


initUIDialog()

protected initUIDialog(): void

Defined in: src/ui/dialogs/basedialog.tsx:191

Initializes jQuery UI dialog-specific behavior.

Returns

void

Inherited from

BaseDialog.initUIDialog


initValidator()

protected initValidator(): void

Defined in: src/ui/dialogs/basedialog.tsx:295

Initializes the form validator.

Returns

void

Inherited from

BaseDialog.initValidator


internalRenderContents()

internalRenderContents(): void

Defined in: src/ui/widgets/widget.ts:462

Renders the widget's contents and runs any queued after-render callbacks.

Returns

void

Inherited from

BaseDialog.internalRenderContents


isStaticPanel()

protected isStaticPanel(): boolean

Defined in: src/ui/dialogs/basedialog.tsx:140

Whether the dialog renders as a static panel.

Returns

boolean

True when static.

Inherited from

BaseDialog.isStaticPanel


legacyTemplateRender()

protected legacyTemplateRender(): boolean

Defined in: src/ui/widgets/widget.ts:487

Renders the widget from a legacy getTemplate string, if defined.

Returns

boolean

True if a legacy template was rendered.

Inherited from

BaseDialog.legacyTemplateRender


onChange()

protected onChange(args): PromiseLike<any>

Defined in: src/ui/datagrid/columnpickerdialog.tsx:189

Invokes the change callback with the given arguments.

Parameters

args

ColumnPickerChangeArgs

Change arguments.

Returns

PromiseLike<any>

Result of the change callback.


onClose()

onClose(handler, opt?): void

Defined in: src/ui/dialogs/basedialog.tsx:253

Attaches a dialog/modal/panel close event handler. See Dialog.close for more info.

Parameters

handler

(result?, e?) => void

opt?
before?

boolean

oneOff?

boolean

Returns

void

Inherited from

BaseDialog.onClose


onDialogClose()

protected onDialogClose(result?): void

Defined in: src/ui/dialogs/basedialog.tsx:331

Hook invoked when the dialog closes; destroys the dialog and removes its element.

Parameters

result?

string

The close result.

Returns

void

Inherited from

BaseDialog.onDialogClose


onDialogOpen()

protected onDialogOpen(): void

Defined in: src/ui/datagrid/columnpickerdialog.tsx:534

Called when the dialog opens; builds the column list and focuses search.

Returns

void

Overrides

BaseDialog.onDialogOpen


onOpen()

onOpen(handler, opt?): void

Defined in: src/ui/dialogs/basedialog.tsx:258

Attaches a dialog/modal/panel open event handler. See Dialog.open for more info.

Parameters

handler

(e?) => void

opt?
before?

boolean

oneOff?

boolean

Returns

void

Inherited from

BaseDialog.onOpen


raiseAfterInit()

protected raiseAfterInit(): void

Defined in: src/ui/dialogs/basedialog.tsx:234

Raises onAfterInit of the class and of the dialog, once. A dialog that raises it itself, e.g. PropertyDialog, calls it when its initialization ends; others may call it at the end of their constructor, else it is called when the dialog is opened first.

Returns

void

Inherited from

BaseDialog.raiseAfterInit


render()

render(): any

Defined in: src/ui/widgets/widget.ts:449

Returns the main element for this widget or the document fragment. As widgets may get their elements from props unlike regular JSX widgets, this method should not be overridden. Override renderContents() instead.

Returns

any

Inherited from

BaseDialog.render


renderContents()

protected renderContents(): any

Defined in: src/ui/datagrid/columnpickerdialog.tsx:222

Renders the dialog contents.

Returns

any

The rendered dialog content.

Overrides

BaseDialog.renderContents


reorderColumns()

protected reorderColumns(columnIds, setVisible?, restoredDefaults?): void

Defined in: src/ui/datagrid/columnpickerdialog.tsx:277

Reorders columns using the configured handler.

Parameters

columnIds

string[]

New column order.

setVisible?

string[]

Optional column ids to set visible.

restoredDefaults?

boolean

Whether this reorder restores defaults.

Returns

void


resetValidation()

protected resetValidation(): void

Defined in: src/ui/dialogs/basedialog.tsx:306

Resets all validation state.

Returns

void

Inherited from

BaseDialog.resetValidation


syncOrAsyncThen()

protected syncOrAsyncThen<T>(syncMethod, asyncMethod, then): void

Defined in: src/ui/widgets/widget.ts:514

Runs a method synchronously or asynchronously depending on the widget's useAsync flag, then invokes a continuation.

Type Parameters

T

T

Parameters

syncMethod

() => T

The synchronous method to run.

asyncMethod

() => PromiseLike<T>

The asynchronous method to run.

then

(v) => void

The continuation invoked with the result.

Returns

void

Inherited from

BaseDialog.syncOrAsyncThen


toggleColumns()

protected toggleColumns(columnIds, show?): Column<any>[]

Defined in: src/ui/datagrid/columnpickerdialog.tsx:176

Toggles visibility of the specified columns.

Parameters

columnIds

string[]

Column ids to toggle.

show?

boolean

Whether to show (true) or hide (false) the columns; defaults to toggling.

Returns

Column<any>[]

The columns whose visibility changed.


updateToggleAllValue()

protected updateToggleAllValue(): boolean

Defined in: src/ui/datagrid/columnpickerdialog.tsx:372

Updates the toggle-all checkbox to reflect the current visibility state.

Returns

boolean

The new checked state of the toggle-all checkbox.


useIdPrefix()

protected useIdPrefix(): IdPrefixType

Defined in: src/ui/widgets/widget.ts:525

Returns an id prefix helper for resolving child element ids.

Returns

IdPrefixType

An IdPrefixType proxy for this widget's id prefix.

Inherited from

BaseDialog.useIdPrefix


validateForm()

protected validateForm(): boolean

Defined in: src/ui/dialogs/basedialog.tsx:314

Validates the form.

Returns

boolean

True when the form is valid.

Inherited from

BaseDialog.validateForm


create()

static create<TWidget, P>(params): TWidget

Defined in: src/ui/widgets/widget.ts:333

Creates a widget instance from the given params, appending its element to the container and invoking the init/init callbacks.

Type Parameters

TWidget

TWidget extends Widget<P>

P

P

Parameters

params

CreateWidgetParams<TWidget, P>

The widget creation params.

Returns

TWidget

The created widget instance.

Inherited from

BaseDialog.create


createDefaultElement()

static createDefaultElement(): HTMLDivElement

Defined in: src/ui/dialogs/basedialog.tsx:22

Creates the default DOM element for a widget.

Returns

HTMLDivElement

A new div element.

Inherited from

BaseDialog.createDefaultElement


createToolButton()

static createToolButton(optOrDataGrid): ToolButton

Defined in: src/ui/datagrid/columnpickerdialog.tsx:408

Creates a toolbar button that opens the column picker dialog.

Parameters

optOrDataGrid

Options or a data grid to derive options from.

IDataGrid | ColumnPickerDialogOptions

Returns

ToolButton

Tool button definition.


getWidgetName()

static getWidgetName(type): string

Defined in: src/ui/widgets/widget.ts:256

Returns the widget name for a type, used for association and unique names.

Parameters

type

Function

The widget type.

Returns

string

The widget name.

Inherited from

BaseDialog.getWidgetName


isDeferredInit()

static isDeferredInit(type, requested?): boolean

Defined in: src/ui/widgets/widget.ts:118

Gets whether a widget of a type defers its initialization to deferredInit, which init or initAsync runs once all the constructors are done, and which may wait. It is as the DeferInitAttribute (see Attributes.deferInit) of the type or a base class says, true for a class that overrides deferredInit, else as defaultDeferInit says. It throws when the type and its base classes say conflicting things, e.g. a class has false but overrides deferredInit.

Parameters

type

Function

The widget type.

requested?

boolean

Whether the creator of the widget asks for it, see WidgetProps.deferInit, which counts only for a class whose own attribute says "optional".

Returns

boolean

Inherited from

BaseDialog.isDeferredInit


openDialog()

static openDialog(opt): void

Defined in: src/ui/datagrid/columnpickerdialog.tsx:546

Opens a column picker dialog with the given options.

Parameters

opt

ColumnPickerDialogOptions

Options for the dialog.

Returns

void


registerClass()

protected static registerClass<TypeName>(typeName, intfAndAttr?): ClassTypeInfo<TypeName>

Defined in: src/ui/widgets/widget.ts:538

Registers this type as a class with the given type name.

Type Parameters

TypeName

TypeName

Parameters

typeName

StringLiteral<TypeName>

The type name to register.

intfAndAttr?

(InterfaceType | AttributeSpecifier)[]

Optional interfaces and attributes.

Returns

ClassTypeInfo<TypeName>

The class type info.

Inherited from

BaseDialog.registerClass


registerEditor()

protected static registerEditor<TypeName>(typeName, intfAndAttr?): EditorTypeInfo<TypeName>

Defined in: src/ui/widgets/widget.ts:553

Registers this type as an editor with the given type name.

Type Parameters

TypeName

TypeName

Parameters

typeName

StringLiteral<TypeName>

The type name to register.

intfAndAttr?

(InterfaceType | AttributeSpecifier)[]

Optional interfaces and attributes.

Returns

EditorTypeInfo<TypeName>

The editor type info.

Inherited from

BaseDialog.registerEditor