Skip to content
Jump to…

Core

SlickEventData 10

An event object for passing data to event handlers and letting them control propagation. <p>This is pretty much identical to how W3C and jQuery implement events.</p>

stopPropagation

stopPropagation()
Stops event from propagating up the DOM tree.

isPropagationStopped

isPropagationStopped()
Returns whether stopPropagation was called on this event object.

stopImmediatePropagation

stopImmediatePropagation()
Prevents the rest of the handlers from being executed.

isImmediatePropagationStopped

isImmediatePropagationStopped()
Returns whether stopImmediatePropagation was called on this event object.\

getNativeEvent

getNativeEvent()

preventDefault

preventDefault()

isDefaultPrevented

isDefaultPrevented()

addReturnValue

addReturnValue(value: any)
ParameterTypeDescription
valueany

getReturnValue

getReturnValue()

getArguments

getArguments()

SlickEvent 4

A simple publisher-subscriber implementation.

subscribe

subscribe(fn: Handler<ArgType>)
Adds an event handler to be called when the event is fired. <p>Event handler will receive two arguments - an <code>EventData</code> and the <code>data</code> object the event was fired with.<p>
ParameterTypeDescription
fnHandler<ArgType>- Event handler.

unsubscribe

unsubscribe(fn?: Handler<ArgType>)
Removes an event handler added with <code>subscribe(fn)</code>.
ParameterTypeDescription
fn?Handler<ArgType>- Event handler to be removed.

notify

notify(args: ArgType, evt?: SlickEventData<ArgType> | Event | MergeTypes<SlickEventData<ArgType>, Event> | null, scope?: any)
Fires an event notifying all subscribers.
ParameterTypeDescription
argsArgTypeAdditional data object to be passed to all handlers.
evt?SlickEventData<ArgType> | Event | MergeTypes<SlickEventData<ArgType>, Event> | null
scope?any- The scope ("this") within which the handler will be executed. If not specified, the scope will be set to the <code>Event</code> instance.

setPubSubService

setPubSubService(pubSub: BasePubSub)
ParameterTypeDescription
pubSubBasePubSub

SlickEventHandler 3

subscribe

subscribe(event: SlickEvent<T>, handler: Handler<T>)
ParameterTypeDescription
eventSlickEvent<T>
handlerHandler<T>

unsubscribe

unsubscribe(event: SlickEvent<T>, handler: Handler<T>)
ParameterTypeDescription
eventSlickEvent<T>
handlerHandler<T>

unsubscribeAll

unsubscribeAll()

SlickRange 6

A structure containing a range of cells.

isSingleRow

isSingleRow()
Returns whether a range represents a single row.

isSingleCell

isSingleCell()
Returns whether a range represents a single cell.

rowCount

rowCount()
Row Count.

cellCount

cellCount()
Cell Count.

contains

contains(row: number, cell: number)
Returns whether a range contains a given cell.
ParameterTypeDescription
rownumber
cellnumber

toString

toString()
Returns a readable representation of a range.

SlickCopyRange 0

A structure containing a range of cells to copy to.

SlickDragExtendHandle 2

Create a handle element for Excel style drag-replace

removeEl

removeEl()

createEl

createEl(activeCellNode: any, showDragHandle?: boolean | 'hover')
ParameterTypeDescription
activeCellNodeany
showDragHandle?boolean | 'hover'

SlickNonDataItem 0

A base class that all special / non-data rows (like Group and GroupTotals) derive from.

SlickGroup 1

Information about a group of rows.

equals

equals(group: SlickGroup): boolean
Compares two Group instances.
ParameterTypeDescription
groupSlickGroupGroup instance to compare to.

returns boolean

SlickGroupTotals 0

Information about group totals. An instance of GroupTotals will be created for each totals row and passed to the aggregators so that they can store arbitrary data in it. That data can later be accessed by group totals formatters during the display.

SlickEditorLock 5

A locking helper to track the active edit controller and ensure that only a single controller can be active at a time. This prevents a whole class of state and validation synchronization issues. An edit controller (such as SlickGrid) can query if an active edit is in progress and attempt a commit or cancel before proceeding.

isActive

isActive(editController?: EditController): boolean
Returns true if a specified edit controller is active (has the edit lock). If the parameter is not specified, returns true if any edit controller is active.
ParameterTypeDescription
editController?EditController

returns boolean

activate

activate(editController: EditController)
Sets the specified edit controller as the active edit controller (acquire edit lock). If another edit controller is already active, and exception will be throw new Error(.
ParameterTypeDescription
editControllerEditControlleredit controller acquiring the lock

deactivate

deactivate(editController: EditController)
Unsets the specified edit controller as the active edit controller (release edit lock). If the specified edit controller is not the active one, an exception will be throw new Error(.
ParameterTypeDescription
editControllerEditControlleredit controller releasing the lock

commitCurrentEdit

commitCurrentEdit(): boolean
Attempts to commit the current edit by calling "commitCurrentEdit" method on the active edit controller and returns whether the commit attempt was successful (commit may fail due to validation errors, etc.). Edit controller's "commitCurrentEdit" must return true if the commit has succeeded and false otherwise. If no edit controller is active, returns true.

returns boolean

cancelCurrentEdit

cancelCurrentEdit(): boolean
Attempts to cancel the current edit by calling "cancelCurrentEdit" method on the active edit controller and returns whether the edit was successfully cancelled. If no edit controller is active, returns true.

returns boolean

BindingEventService 6

A simple binding event service to keep track of all JavaScript events with callback listeners, it allows us to unbind event(s) and their listener(s) by calling a simple unbind method call. Unbinding is a necessary step to make sure that all event listeners are removed to avoid memory leaks when destroing the grid

getBoundedEvents

getBoundedEvents()

destroy

destroy()

bind

bind(element: Element | Window | Document, eventName: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions, groupName?)
Bind an event listener to any element
ParameterTypeDescription
elementElement | Window | Document
eventNamestring
listenerEventListenerOrEventListenerObject
options?boolean | AddEventListenerOptions
groupName?

unbind

unbind(element: Element | Window | Document, eventName: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions)
Unbind all will remove every every event handlers that were bounded earlier
ParameterTypeDescription
elementElement | Window | Document
eventNamestring
listenerEventListenerOrEventListenerObject
options?boolean | EventListenerOptions

unbindByEventName

unbindByEventName(element: Element | Window | Document, eventName: string)
ParameterTypeDescription
elementElement | Window | Document
eventNamestring

unbindAll

unbindAll(groupName?: string | string[])
Unbind all event listeners that were bounded, optionally provide a group name to unbind all listeners assigned to that specific group only.
ParameterTypeDescription
groupName?string | string[]

Utils 32

isFunction

isFunction(obj: any)
ParameterTypeDescription
objany

isPlainObject

isPlainObject(obj: any)
ParameterTypeDescription
objany

calculateAvailableSpace

calculateAvailableSpace(element: HTMLElement)
ParameterTypeDescription
elementHTMLElement

extend

extend(args: any[]): T
ParameterTypeDescription
argsany[]

returns T

createDomElement

createDomElement(tagName: T, elementOptions?: null | { [P in K]: InferDOMType<HTMLElementTagNameMap[T][P]> }, appendToParent?: Element): HTMLElementTagNameMap[T]
Create a DOM Element with any optional attributes or properties. It will only accept valid DOM element properties that `createElement` would accept. For example: `createDomElement('div', { className: 'my-css-class' })`, for style or dataset you need to use nested object `{ style: { display: 'none' }} The last argument is to optionally append the created element to a parent container element.
ParameterTypeDescription
tagNameT- html tag
elementOptions?null | { [P in K]: InferDOMType<HTMLElementTagNameMap[T][P]> }
appendToParent?Element- parent element to append to

returns HTMLElementTagNameMap[T]

getHtmlStringOutput

getHtmlStringOutput(input: DocumentFragment | HTMLElement | string | number, type?: 'innerHTML' | 'outerHTML'): string
From any input provided, return the HTML string (when a string is provided, it will be returned "as is" but when it's a number it will be converted to string) When detecting HTMLElement/DocumentFragment, we can also specify which HTML type to retrieve innerHTML or outerHTML. We can get the HTML by looping through all fragment `childNodes`
ParameterTypeDescription
inputDocumentFragment | HTMLElement | string | number
type?'innerHTML' | 'outerHTML'- when the input is a DocumentFragment or HTMLElement, which type of HTML do you want to return? 'innerHTML' or 'outerHTML'

returns string

emptyElement

emptyElement(element?: T | null): T | undefined | null
ParameterTypeDescription
element?T | null

returns T | undefined | null

classNameToList

classNameToList(className?): string[]
Accepts string containing the class or space-separated list of classes, and returns list of individual classes. Method properly takes into account extra whitespaces in the `className` e.g.: " class1 class2 " => will result in `['class1', 'class2']`.
ParameterTypeDescription
className?- space separated list of class names

returns string[]

innerSize

innerSize(elm: HTMLElement, type: 'height' | 'width')
ParameterTypeDescription
elmHTMLElement
type'height' | 'width'

isDefined

isDefined(value: T | undefined | null): value is T
ParameterTypeDescription
valueT | undefined | null

returns value is T

getElementProp

getElementProp(elm: HTMLElement & { getComputedStyle?: () => CSSStyleDeclaration }, property: string)
ParameterTypeDescription
elmHTMLElement & { getComputedStyle?: () => CSSStyleDeclaration }
propertystring

getFunctionDetails

getFunctionDetails(fn: AnyFunction, addReturn?)
Get the function details (param & body) of a function. It supports regular function and also ES6 arrow functions
ParameterTypeDescription
fnAnyFunction- function to analyze
addReturn?- when using ES6 function as single liner, we could add the missing `return ...`

insertAfterElement

insertAfterElement(referenceNode: HTMLElement, newNode: HTMLElement)
ParameterTypeDescription
referenceNodeHTMLElement
newNodeHTMLElement

isEmptyObject

isEmptyObject(obj: any)
ParameterTypeDescription
objany

noop

noop()

offset

offset(el: HTMLElement | null)
ParameterTypeDescription
elHTMLElement | null

windowScrollPosition

windowScrollPosition()

width

width(el: HTMLElement, value?: number | string): number | void
ParameterTypeDescription
elHTMLElement
value?number | string

returns number | void

height

height(el: HTMLElement, value?: number | string): number | void
ParameterTypeDescription
elHTMLElement
value?number | string

returns number | void

setStyleSize

setStyleSize(el: HTMLElement, style: keyof P, val?: number | string | Function): void
ParameterTypeDescription
elHTMLElement
stylekeyof P
val?number | string | Function

returns void

setStyles

setStyles(element: T, styles: P): void
ParameterTypeDescription
elementT
stylesP

returns void

contains

contains(parent: HTMLElement, child: HTMLElement)
ParameterTypeDescription
parentHTMLElement
childHTMLElement

isHidden

isHidden(el: HTMLElement)
ParameterTypeDescription
elHTMLElement

parents

parents(el: HTMLElement | ParentNode, selector?: string)
ParameterTypeDescription
elHTMLElement | ParentNode
selector?string

toFloat

toFloat(value: string | number)
ParameterTypeDescription
valuestring | number

show

show(el: HTMLElement | HTMLElement[], type?)
ParameterTypeDescription
elHTMLElement | HTMLElement[]
type?

hide

hide(el: HTMLElement | HTMLElement[])
ParameterTypeDescription
elHTMLElement | HTMLElement[]

slideUp

slideUp(el: HTMLElement | HTMLElement[], callback: Function)
ParameterTypeDescription
elHTMLElement | HTMLElement[]
callbackFunction

slideDown

slideDown(el: HTMLElement | HTMLElement[], callback: Function)
ParameterTypeDescription
elHTMLElement | HTMLElement[]
callbackFunction

slideAnimation

slideAnimation(el: HTMLElement | HTMLElement[], slideDirection: 'slideDown' | 'slideUp', callback: Function)
ParameterTypeDescription
elHTMLElement | HTMLElement[]
slideDirection'slideDown' | 'slideUp'
callbackFunction

applyDefaults

applyDefaults(targetObj: any, srcObj: any)
ParameterTypeDescription
targetObjany
srcObjany

addSlickEventPubSubWhenDefined

addSlickEventPubSubWhenDefined(pubSub?: BasePubSub, scope?: T)
User could optionally add PubSub Service to SlickEvent When it is defined then a SlickEvent `notify()` call will also dispatch it by using the PubSub publish() method
ParameterTypeDescription
pubSub?BasePubSub
scope?T

SelectionUtils 7

normaliseDragRange

normaliseDragRange(rawRange: DragRange)
ParameterTypeDescription
rawRangeDragRange

copyRangeIsLarger

copyRangeIsLarger(baseRange: SlickRange, copyToRange: SlickRange): boolean
ParameterTypeDescription
baseRangeSlickRange
copyToRangeSlickRange

returns boolean

normalRangeOppositeCellFromCopy

normalRangeOppositeCellFromCopy(normalisedDragRange: DragRange, targetCell: { row: number; cell: number }): { row: number; cell: number }
Returns the anchor (opposite) cell to use while dragging the drag-extend handle. Anchoring on the range start lets the drag shrink the range (Excel behavior), while dragging past the start anchors on the range end so that it expands in the opposite direction instead.
ParameterTypeDescription
normalisedDragRangeDragRange
targetCell{ row: number; cell: number }

returns { row: number; cell: number }

verticalTargetRange

verticalTargetRange(baseRange: SlickRange, copyToRange: SlickRange)
ParameterTypeDescription
baseRangeSlickRange
copyToRangeSlickRange

horizontalTargetRange

horizontalTargetRange(baseRange: SlickRange, copyToRange: SlickRange)
ParameterTypeDescription
baseRangeSlickRange
copyToRangeSlickRange

cornerTargetRange

cornerTargetRange(baseRange: SlickRange, copyToRange: SlickRange)
ParameterTypeDescription
baseRangeSlickRange
copyToRangeSlickRange

copyCellsToTargetRange

copyCellsToTargetRange(baseRange: SlickRange, targetRange: SlickRange, grid: SlickGrid)
ParameterTypeDescription
baseRangeSlickRange
targetRangeSlickRange
gridSlickGrid

RowPositionIndexer 4

RowPositionIndexer - a prefix-sum index of row top positions, used by SlickGrid when variable row height mode is enabled (i.e. when a `rowHeightProvider` grid option is supplied). `rowPos[i]` holds the virtual top pixel position of row `i` (i.e. the summed heights of all preceding rows) and `rowPos[rowCount]` holds the total height of all indexed rows, which makes row-to-position lookups an O(1) array read and position-to-row lookups an O(log n) binary search. Row indexes are expected to be 0 or greater (guaranteed by the grid core; user-provided indexes are validated in the public grid methods). Rows at or beyond the indexed range extrapolate linearly using the default row height, mirroring the fixed-row-height arithmetic it replaces (needed for the Add-New row and `leaveSpaceForNewRows` padding).

rebuild

rebuild(rowCount: number, defaultRowHeight: number, getRowHeight: (row: number) => number | undefined): void
Rebuilds the index by querying the height of every row. O(n) - the provided callback is called once per row and must therefore be fast (a simple lookup, no DOM access).
ParameterTypeDescription
rowCountnumber- The number of rows to index.
defaultRowHeightnumber- The height used when the callback returns `undefined` and for extrapolating beyond the indexed range.
getRowHeight(row: number) => number | undefined- Returns the height of a row in pixels, or `undefined` to use the default.

returns void

top

top(row: number): number
Returns the virtual top pixel position of a row.
ParameterTypeDescription
rownumber- The row index (>= 0); indexes beyond the indexed range extrapolate using the default row height.

returns number

height

height(row: number): number
Returns the height of a row.
ParameterTypeDescription
rownumber- The row index (>= 0); indexes beyond the indexed range return the default row height.

returns number

rowAt

rowAt(y: number): number
Returns the index of the row containing a virtual vertical pixel position. Positions below zero return row 0; positions beyond the indexed range extrapolate using the default row height (results may be beyond the last row - callers clamp, as in fixed mode).
ParameterTypeDescription
ynumber- The virtual vertical position in pixels.

returns number

Enums & constants 3

keyCode

type const

SPACE = 8 BACKSPACE = 8 DELETE = 46 DOWN = 40 END = 35 ENTER = 13 ESCAPE = 27 HOME = 36 INSERT = 45 LEFT = 37 PAGE_DOWN = 34 PAGE_UP = 33 RIGHT = 39 TAB = 9 UP = 38 A = 65

GridAutosizeColsMode

type const

None = "NOA" LegacyOff = "LOF" LegacyForceFit = "LFF" IgnoreViewport = "IGV" FitColsToViewport = "FCV" FitViewportToCols = "FVC"

WidthEvalMode

type const

Auto = "AUTO" TextOnly = "CANV" HTML = "HTML"