Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ListModel

A model for list data.

Hierarchy

Index

Constructors

constructor

Properties

Protected _config

Protected _data

_data: JsonObject[] = []

Protected _eventBus

_eventBus: EventBus = new EventBus(this)

Methods

Protected _check

  • _check(): void
  • Returns void

Protected _fire

  • _fire(type: string, args?: any[]): void
  • Parameters

    • type: string
    • Optional args: any[]

    Returns void

Protected _initConfig

add

  • Add new data into the tail.

    Parameters

    Returns this

addSorter

  • addSorter(field: string, dir?: "asc" | "desc"): void
  • Parameters

    • field: string
    • Optional dir: "asc" | "desc"

    Returns void

clear

  • clear(silent?: boolean): this
  • Parameters

    • Optional silent: boolean

    Returns this

clearSorters

  • clearSorters(): void
  • Returns void

clone

  • clone(): this
  • Returns this

destroy

  • destroy(): void
  • Returns void

getData

getModels

  • getModels<T>(klass?: Klass<T>): T[]
  • Type parameters

    Parameters

    • Optional klass: Klass<T>

    Returns T[]

getRow

getRowById

  • Parameters

    • id: number | string

    Returns JsonObject

getRowModel

  • getRowModel<T>(index: number, klass?: Klass<T>): T
  • Type parameters

    Parameters

    • index: number
    • Optional klass: Klass<T>

    Returns T

getSorterBy

  • getSorterBy(fieldName: string): Sorter
  • Parameters

    • fieldName: string

    Returns Sorter

indexOfId

  • indexOfId(id: number | string): number
  • Parameters

    • id: number | string

    Returns number

iniData

  • iniData(): any
  • iniData(data: any): this
  • Returns any

  • Parameters

    • data: any

    Returns this

insert

  • Insert new data into the index.

    Parameters

    Returns this

isDestroyed

  • isDestroyed(): boolean
  • Returns boolean

isEmpty

  • isEmpty(): boolean
  • Returns boolean

load

  • load using its configured query.

    Type parameters

    • R

    Parameters

    Returns Promise<ResultSet<R>>

modelKlass

off

  • off(type?: string): this
  • Parameters

    • Optional type: string

    Returns this

on

  • on<H>(type: string, fn: H, once?: boolean): this
  • Type parameters

    • H

    Parameters

    • type: string
    • fn: H
    • Optional once: boolean

    Returns this

reload

removeAt

  • removeAt(index: number, silent?: boolean): this
  • Parameters

    • index: number
    • Optional silent: boolean

    Returns this

removeSorter

  • removeSorter(field: string): void
  • Parameters

    • field: string

    Returns void

reset

  • reset(): this
  • Returns this

setData

  • setData(data: JsonObject[], silent?: boolean): this
  • Read data into model.

    Parameters

    • data: JsonObject[]
    • Optional silent: boolean

      ignore events

    Returns this

size

  • size(): number
  • Returns number

sort

  • sort(field: string, dir?: "desc" | "asc"): Promise<any>
  • Parameters

    • field: string
    • Optional dir: "desc" | "asc"

    Returns Promise<any>

validate

  • validate(): string | boolean
  • Returns string | boolean

validateRow

  • validateRow(index: number): string | boolean
  • Parameters

    • index: number

    Returns string | boolean