Primary component class - used to create table instances with an array of features.
Metadata is provided to JSONMetaTable instances as an array of associative objects, each object gets merged with the core module defaults:
{
name: '',
label: '',
type: 'text',
info: null,
options: null,
editable: true,
sortable: true,
filterable: true,
renderer: undefined,
filter: undefined,
rendererOptions: {}
}name: Column name (unique identifier)label: Column label - used to display in the elementtype: Type of data - used to determine the type of renderer to use for displaying/editinginfo: Column info to display as element's title attributeoptions: Array of associative objects to use in combination with 'select' type - object format: { value: '', label: '' }editable: Column is editablesortable: Column is sortablefilterable: Column is filterable - if false, this column is skipped in all filter searches and will have no filter in its<th>elementrenderer: Specific renderer to use for this column - overrides type-based renderer selection - must extendBaseRendererabstract classfilter: Specific filter to use for this column - overrides type-based filter selection - must extendBaseFilterabstract classrendererOptions: Options for renderer instance to use
Data is provided to JSONMetaTable instances as an array of associative objects
id: Unique identifier for rowtrClassName: Class to add to row<tr>elementvalues: Associative object of row values - values are only rendered if included in the table's metadata, in the order defined by the metadatadisplayValues: Associative object of row values specific to renderer display only
Container to append JSON meta table instance's <table> element to - can provide an HTML node, or string to be used in document.querySelector().
Table-specific options.
tableClass: Class added to<table>elementthContainerClass: Class added to the text container inside<th>elementshasInfoClass: Class added to<th>elements for columns that have info metadatasortableClass: Class added to<th>elements for columns that are sortablesortAscClass: Class added to<th>element for column currently being sorted in ascending ordersortDescClass: Class added to<th>element for column currently being sorted in descending orderfilterableClass: Class added to<th>elements for columns that are filterableactionsContainerClass: Class added to the container element the row actions are appended todeleteActionClass: Class added to the delete action buttoninlineEditing: Enable inline editing of row datainlineDeleting: Enable inline deleting of rowscolumnFiltering: Enable column filtering, using filter controls in the<th>elements
Options that are passed to filter instances used for column-specific filtering.
containerClass: Class added to filter container elementbuttonClass: Class added to<button>elementinputContainerClass: Class added to the<input>container elementinputHasValueClass: Class added to the container element when the filter has a value setemptyOptionText: Text for empty option text for filters using the<select>elementtrueOptionText: Text forCheckboxFilterfilter typetrueoptionfalseOptionText: Text forCheckboxFilterfilter typefalseoptionplaceholderText: Text to use for<input>placeholderattributetypingUpdateDelay: Time in milliseconds to delay updating the filter value when typing
Array of associative objects to use for row action generation.
Available object properties:
name: Name of action - used as a unique identifier when defining action in row objecttype: Action type - string value used to get an action type from theactionTypesobjecttext: Text to append to action<button>elementtitle: Text to use for action<button>titleattributeclassName: Class to add to action<button>elementevent: Function to trigger when action is clickedurl: URL to navigate to forLinkActioninstances - can reference therowobject. eg:'/post/${row.values.id}/${row.values.slug}/'isNewWindow: OpenLinkActionURL in new window (defaultfalse)windowName: Name forLinkActionnew windowwindowFeatures: Features passed toLinkActionnew window's windowFeatures parameter
Associative object of filter types, referenced . Merged with core module defaults:
{
text: TextFilter,
select: SelectFilter,
checkbox: CheckboxFilter
}Associative object of renderer types. Merged with core module defaults:
{
text: TextRenderer,
number: NumberRenderer,
select: SelectRenderer,
checkbox: CheckboxRenderer,
datetime: DateTimeRenderer
}Associative object of action types. Merged with core module defaults:
{
button: ButtonAction,
link: LinkAction
}Public control methods to be accessed on an instance are as follows:
Set table metadata and re-render table.
Set table data and re-render table.
Sort by provided column and direction parameters.
Filter data by provided associative object.
Filter data by provided column and search parameters.
Filter data by general text search, searching filterable columns.
Delete row using provided row parameter. This can be the row id or row object.
The class triggers the following events:
Triggered before a row is updated when editing using the table's inline editing functionality.
{
row: row, // Row being edited
meta: meta, // Row column metadata
newValue: newValue // New value to update to
newDisplayValue: newDisplayValue // New display value to update to
}Triggered after a row is updated when editing using the table's inline editing functionality.
{
row: row, // Row that was edited
meta: meta, // Row column metadata
}Triggered before table body is rendered.
Triggered after table body is rendered.
Triggered before table is rendered.
Triggered after table is rendered.
Triggered before new metadata is set.
{
newMetadata: newMetadata // New metadata to be set
}Triggered after new metadata is set.
Triggered before new data is set.
{
newData: newData // New data to be set
}Triggered after new data is set.
Triggered before table is sorted by column.
{
column: column, // Column to sort by
direction: direction // Direction to sort column
}Triggered after table is sorted by column.
{
column: column, // Column sorted by
direction: direction // Direction column was sorted
}Triggered before table data is filtered by multiple columns.
{
values: values // New values to filter data by
}Triggered after table data is filtered by multiple columns.
{
values: values // Values data was filtered by
}Triggered before table data is filtered by column.
{
column: column, // Column to filter data by
search: search // Search value to filter data by
}Triggered after table data is filtered by column.
{
column: column, // Column data was filtered by
search: search // Search value data was filtered by
}Triggered before table data is filtered by general search string.
{
search: search // Search value to filter data by
}Triggered after table data is filtered by general search string.
{
search: search // Search value data was filtered by
}Triggered before a row is deleted from table data.
{
id: id // Row id
}Triggered after a row is deleted from table data.
{
id: id // Row id
}