Skip to content

@serenity-is/corelib / QuickFilterBar

Class: QuickFilterBar<P>

Defined in: src/ui/datagrid/quickfilterbar.tsx:41

A bar that renders quick filters for a grid, including date ranges, boolean toggles, and custom filter widgets, and submits their values with list requests.

Extends

Type Parameters

P

P extends QuickFilterBarOptions = QuickFilterBarOptions

Options type for the widget.

Constructors

Constructor

new QuickFilterBar<P>(props): QuickFilterBar<P>

Defined in: src/ui/datagrid/quickfilterbar.tsx:49

Creates a quick filter bar and adds all configured filters.

Parameters

props

WidgetProps<P>

Widget props including the filter definitions.

Returns

QuickFilterBar<P>

Overrides

Widget.constructor

Properties

domNode

readonly domNode: HTMLElement

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

The DOM node this widget is bound to.

Inherited from

Widget.domNode


idPrefix

readonly idPrefix: string

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

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

Inherited from

Widget.idPrefix


onChange()

onChange: (e) => void

Defined in: src/ui/datagrid/quickfilterbar.tsx:425

Callback invoked when a quick filter value changes.

Parameters

e

Event

Returns

void


options

protected readonly options: WidgetProps<P>

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

The widget's options/props.

Inherited from

Widget.options


uniqueName

readonly uniqueName: string

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

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

Inherited from

Widget.uniqueName


[typeInfo]

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

Defined in: src/ui/datagrid/quickfilterbar.tsx:43

Overrides

Widget.[typeInfo]


isComponent

readonly static isComponent: true = true

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

Inherited from

Widget.isComponent

Accessors

element

Get Signature

get element(): Fluent

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

Returns a Fluent(this.domNode) object

Returns

Fluent

Inherited from

Widget.element


props

Get Signature

get props(): WidgetProps<P>

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

Returns the widget's props/options.

Returns

WidgetProps<P>

Inherited from

Widget.props

Methods

add()

add<TWidget, TOptions>(opt): TWidget

Defined in: src/ui/datagrid/quickfilterbar.tsx:86

Adds a quick filter widget to the bar and wires its submit handler.

Type Parameters

TWidget

TWidget extends Widget<any>

TOptions

TOptions

Parameters

opt

QuickFilter<TWidget, TOptions>

Quick filter definition.

Returns

TWidget

The created widget instance.


addBoolean()

addBoolean(field, title?, yes?, no?): SelectEditor

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

Adds a boolean quick filter for the specified field.

Parameters

field

string

Field name the filter is bound to.

title?

string

Optional display title.

yes?

string

Optional text for the true option.

no?

string

Optional text for the false option.

Returns

SelectEditor

The created select editor.


addCssClass()

protected addCssClass(): void

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

Adds the widget's CSS class to its DOM node.

Returns

void

Inherited from

Widget.addCssClass


addDateRange()

addDateRange(field, title?): DateEditor

Defined in: src/ui/datagrid/quickfilterbar.tsx:194

Adds a date range quick filter for the specified field.

Parameters

field

string

Field name the filter is bound to.

title?

string

Optional display title.

Returns

DateEditor

The created date editor.


addDateTimeRange()

addDateTimeRange(field, title?): DateTimeEditor<DateTimeEditorOptions>

Defined in: src/ui/datagrid/quickfilterbar.tsx:283

Adds a date-time range quick filter for the specified field.

Parameters

field

string

Field name the filter is bound to.

title?

string

Optional display title.

Returns

DateTimeEditor<DateTimeEditorOptions>

The created date-time editor.


addSeparator()

addSeparator(): void

Defined in: src/ui/datagrid/quickfilterbar.tsx:77

Adds a visual separator to the bar.

Returns

void


addValidationRule()

Call Signature

addValidationRule(rule, uniqueName?): void

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

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

Widget.addValidationRule

Call Signature

addValidationRule(uniqueName, rule): void

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

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

Widget.addValidationRule


afterRender()

protected afterRender(callback): void

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

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

Widget.afterRender


byId()

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

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

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

Widget.byId


change()

change(handler): void

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

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

Parameters

handler

(e) => void

The change event handler.

Returns

void

Inherited from

Widget.change


changeSelect2()

changeSelect2(handler): void

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

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

Parameters

handler

(e) => void

The change event handler.

Returns

void

Inherited from

Widget.changeSelect2


deferRender()

protected deferRender(): boolean

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

Determines whether rendering should be deferred until init is called.

Returns

boolean

True to defer rendering.

Inherited from

Widget.deferRender


destroy()

destroy(): void

Defined in: src/ui/datagrid/quickfilterbar.tsx:432

Cleans up submit handlers and delegates to the base destroy.

Returns

void

Overrides

Widget.destroy


find()

find<TWidget>(type, field): TWidget

Defined in: src/ui/datagrid/quickfilterbar.tsx:451

Finds the widget instance for a quick filter by field name.

Type Parameters

TWidget

TWidget

Parameters

type

(...args) => TWidget

Widget constructor type.

field

string

Field name of the quick filter.

Returns

TWidget

The widget instance.


findById()

protected findById<TElement>(id): TElement

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

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

Widget.findById


getCssClass()

protected getCssClass(): string

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

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

Returns

string

The space-separated CSS class string.

Inherited from

Widget.getCssClass


getCustomAttribute()

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

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

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

Widget.getCustomAttribute


getGridField()

getGridField(): Fluent

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

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

Returns

Fluent

A Fluent wrapper for the grid field.

Inherited from

Widget.getGridField


init()

init(): this

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

Initializes the widget, rendering its contents if rendering was deferred.

Returns

this

This widget instance.

Inherited from

Widget.init


internalRenderContents()

internalRenderContents(): void

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

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

Returns

void

Inherited from

Widget.internalRenderContents


legacyTemplateRender()

protected legacyTemplateRender(): boolean

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

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

Returns

boolean

True if a legacy template was rendered.

Inherited from

Widget.legacyTemplateRender


onSubmit()

onSubmit(request): void

Defined in: src/ui/datagrid/quickfilterbar.tsx:441

Invokes all registered submit handlers with the given list request.

Parameters

request

ListRequest

The list request being prepared.

Returns

void


render()

render(): any

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

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

Widget.render


renderContents()

protected renderContents(): any

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

Renders the widget's contents. Override this to provide custom content.

Returns

any

The rendered contents.

Inherited from

Widget.renderContents


syncOrAsyncThen()

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

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

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

Widget.syncOrAsyncThen


tryFind()

tryFind<TWidget>(type, field): TWidget

Defined in: src/ui/datagrid/quickfilterbar.tsx:463

Tries to find the widget instance for a quick filter by field name.

Type Parameters

TWidget

TWidget

Parameters

type

(...args) => TWidget

Widget constructor type.

field

string

Field name of the quick filter.

Returns

TWidget

The widget instance, or null if not found.


useIdPrefix()

protected useIdPrefix(): IdPrefixType

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

Returns an id prefix helper for resolving child element ids.

Returns

IdPrefixType

An IdPrefixType proxy for this widget's id prefix.

Inherited from

Widget.useIdPrefix


boolean()

static boolean(field, title?, yes?, no?): QuickFilter<SelectEditor<SelectEditorOptions>, SelectEditorOptions>

Defined in: src/ui/datagrid/quickfilterbar.tsx:393

Creates a boolean quick filter definition for the specified field.

Parameters

field

string

Field name the filter is bound to.

title?

string

Optional display title.

yes?

string

Optional text for the true option.

no?

string

Optional text for the false option.

Returns

QuickFilter<SelectEditor<SelectEditorOptions>, SelectEditorOptions>

A quick filter definition for a boolean value.


create()

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

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

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

Widget.create


createDefaultElement()

static createDefaultElement(): HTMLElement

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

Creates the default DOM element for a widget.

Returns

HTMLElement

A new div element.

Inherited from

Widget.createDefaultElement


dateRange()

static dateRange(field, title?): QuickFilter<DateEditor<DateEditorOptions>, DateTimeEditorOptions>

Defined in: src/ui/datagrid/quickfilterbar.tsx:204

Creates a date range quick filter definition for the specified field.

Parameters

field

string

Field name the filter is bound to.

title?

string

Optional display title.

Returns

QuickFilter<DateEditor<DateEditorOptions>, DateTimeEditorOptions>

A quick filter definition for a date range.


dateTimeRange()

static dateTimeRange(field, title?, useUtc?): QuickFilter<DateTimeEditor<DateTimeEditorOptions>, DateTimeEditorOptions>

Defined in: src/ui/datagrid/quickfilterbar.tsx:294

Creates a date-time range quick filter definition for the specified field.

Parameters

field

string

Field name the filter is bound to.

title?

string

Optional display title.

useUtc?

boolean

Whether the editor should use UTC values.

Returns

QuickFilter<DateTimeEditor<DateTimeEditorOptions>, DateTimeEditorOptions>

A quick filter definition for a date-time range.


getItemData()

static getItemData<TWidget>(filterItem): QuickFilterItemData<TWidget>

Defined in: src/ui/datagrid/quickfilterbar.tsx:70

Returns the per-item data attached to a quick filter element, if any.

Type Parameters

TWidget

TWidget

Parameters

filterItem

Node

The quick filter container element.

Returns

QuickFilterItemData<TWidget>

The item data, or undefined if none was attached.


getWidgetName()

static getWidgetName(type): string

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

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

Widget.getWidgetName


registerClass()

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

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

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

Widget.registerClass


registerEditor()

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

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

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

Widget.registerEditor