-
-
Notifications
You must be signed in to change notification settings - Fork 1
API
new Nativetable(id: number, options?: {
sources?: Object[] = [],
columns?: string[] = [],
filters?: {
$and?: Object = {},
$or?: Object = {}
} = {},
pagination?: {
maxLength?: number = -1
} = {}
} = {})To init a Nativetable object only id argument is required.
In options argument,
-
sourcesis a list of objects the user wants to display in a table. -
columnsis a list of key the user wants to display. When this argument is used, only key incolumnsare displaying. -
filtersis an object which exposes filtering conditions. -
pagination.maxLengthis the maximum number of items shown in one page.
options.filters can contain two keys: $and and $or where conditions are grouped.
In the $and key, the logical operator used between each condition is AND. Similarly, in the $or key, the logical operator used between each condition is OR.
Between $and and $or, the logical operator user is AND.
Between each value of one condition, the logical operator user is OR.
The keys of $and and $or object must be the same keys that you want to filter in options.sources. The value for each key must be an array of wanted value or a closure that returns a boolean and take in parameters the value of the key you want to test in each object of options.sources.
nt.sources: Object[]The sources of the created table
nt.filtered: Object[]It is a read only atribute.
The filtered sources.
If options.filters is not used
the default value of nt.filtered is nt.sources.
nt.paginated: Object[][]It is a read only atribute.
The paginated sources.
If options.pagination.maxLength is not used
the default value of nt.paginated is nt.sources.
nt.columns: string[]The list of keys to use as columns
Only these keys are displaying event if others are available in nt.sources.
It is mandatory to display at least on column.
When nt.columns = [] is used,
Nativetable show all keys available in nt.sources as default.
nt.draw(): voidThis method draw the table in the DOM.
nt.reload(rows?: Object[]): voidForce the reloading of pagination and redraw the table.
If data (rows) is passed in argument,
rows is passed to nt.sources before the reloading.