Skip to content

@serenity-is/corelib / SlickPager

Class: SlickPager<P>

Defined in: src/ui/datagrid/slickpager.tsx:12

Pager widget for SlickGrid / SleekGrid views that provides page navigation, page size selection, and status information. A view that shows a range of the rows instead of a page of them, e.g. the rows it has loaded as the grid is scrolled, gets no page navigation, and a status that tells of its range.

Extends

Type Parameters

P

P extends PagerOptions = PagerOptions

Options type for the widget.

Constructors

Constructor

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

Defined in: src/ui/datagrid/slickpager.tsx:47

Creates a pager for the view specified in the options.

Parameters

props

WidgetProps<P>

Widget props including the view to page.

Returns

SlickPager<P>

Overrides

Widget.constructor

Properties

domNode

readonly domNode: HTMLElement

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

The DOM node this widget is bound to.

Inherited from

Widget.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

Widget.idPrefix


options

protected readonly options: WidgetProps<P>

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

The widget's options/props.

Inherited from

Widget.options


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

Widget.uniqueName


[typeInfo]

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

Defined in: src/ui/datagrid/slickpager.tsx:15

Overrides

Widget.[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

Widget.defaultDeferInit


defaults

readonly static defaults: PagerOptions

Defined in: src/ui/datagrid/slickpager.tsx:22

The defaults of the options of every pager, which a pager or an application can change, e.g. to bring back the first and last page buttons that most pagers leave out, as the page box takes a number anyway.


isComponent

readonly static isComponent: true = true

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

Inherited from

Widget.isComponent

Accessors

element

Get Signature

get element(): Fluent

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

Returns a Fluent(this.domNode) object

Returns

Fluent

Inherited from

Widget.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

Widget.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

Widget.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

Widget.usesDeferredInit

Methods

_changePage()

_changePage(ctype): boolean

Defined in: src/ui/datagrid/slickpager.tsx:160

Changes the current page based on the requested navigation action.

Parameters

ctype

string

Navigation action: "first", "prev", "next", "last", or "input".

Returns

boolean

True if the page change was handled, false otherwise.


_updatePager()

_updatePager(): void

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

Refreshes the pager UI from the current view paging info.

Returns

void


addCssClass()

protected addCssClass(): void

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

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

Returns

void

Inherited from

Widget.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

Widget.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

Widget.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

Widget.afterRender


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

Widget.byId


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

Widget.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

Widget.changeSelect2


deferredInit()

protected deferredInit(): void | PromiseLike<void>

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

Does the initialization of a widget that defers it (see isDeferredInit), once, when init or initAsync is called after all its constructors are done. The base classes initialize what their constructors would, e.g. the contents, the form or the columns, and a subclass does the work its constructor would do after await super.deferredInit(), which may wait too. The part before its first await runs at once, so a widget that is made and inited has its contents.

Returns

void | PromiseLike<void>

Inherited from

Widget.deferredInit


destroy()

destroy(): void

Defined in: src/ui/datagrid/slickpager.tsx:247

Removes the subscription to the view, so a view that outlives its pager does not keep updating it. The grid binding of a scroll view is left alone, as the view belongs to the grid, which may set another pager for it.

Returns

void

Overrides

Widget.destroy


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

Widget.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

Widget.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

Widget.getCustomAttribute


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

Widget.getGridField


getRowRange()

protected getRowRange(info): PagingRowRange

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

Gets the rows the pager tells of, which the view gives for a range view, and are the rows of its current page for a paged one.

Parameters

info

PagingInfo

The paging info of the view.

Returns

PagingRowRange

The rows, or null when there are none.


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

Widget.init


initAsync()

initAsync(): Promise<SlickPager<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<SlickPager<P>>

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

Inherited from

Widget.initAsync


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

Widget.initNow


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

Widget.internalRenderContents


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

Widget.legacyTemplateRender


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

Widget.render


renderContents()

protected renderContents(): any

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

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

Returns

any

The rendered contents.

Inherited from

Widget.renderContents


setDisabled()

protected setDisabled(button, disabled): void

Defined in: src/ui/datagrid/slickpager.tsx:210

Dims a navigation button that can't go anywhere, and tells it to assistive technology.

Parameters

button

HTMLDivElement

The button to set the state of.

disabled

boolean

Whether the button is disabled.

Returns

void


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

Widget.syncOrAsyncThen


updateExtra()

protected updateExtra(info): void

Defined in: src/ui/datagrid/slickpager.tsx:224

Shows the extra content the grid or the view gives before the controls, e.g. the totals of the page and of all the rows. A string is text, an element or a fragment is appended as it is, so the pager never parses markup. It is only rendered again when the content changes.

Parameters

info

PagingInfo

The paging info of the view.

Returns

void


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

Widget.useIdPrefix


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

Widget.create


createDefaultElement()

static createDefaultElement(): HTMLElement

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

Creates the default DOM element for a widget.

Returns

HTMLElement

A new div element.

Inherited from

Widget.createDefaultElement


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

Widget.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

Widget.isDeferredInit


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

Widget.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

Widget.registerEditor