Releases: kjhangiani/datatables-metadata
v0.4.1
v0.4.0
v0.4.0
Updated Metadata plugin with cleaner API, extracted filtering functions into their own separate plugin datatables-improved-filters
New API calls:
Metadata
Store column specific metadata in the datatable. This is used by the filtering functions below, but can also be used to store arbitrary data related to the column as required. This data is state saved if state saving is enabled.
.column().meta()
// retrieve meta information for a column.column().meta(key)
// retrieve meta information for a column, under the keykey
.column().meta.replace(data)
// set the entire column meta to the object passed in asdata
.column().meta.clear()
// remove all metadata for this column.column().meta.set(key, data)
// set thekey
property in the column metadata object todata
.column().meta.merge(key, data)
// merge thekey
property in the column metadata object with the object passed in todata
.column().meta.remove(key)
// remove all metadata underkey
v0.3.0
v0.3.0
Datatables-Metadata plugin initial public release.
See README.md for full details on installation and usage.
Configuration
Enable the extension in your environment via the M
feature flag to Datatables.
This plugin does not render any dom elements, so it's placement in the feature flag list does not matter. The feature flag is used to instantiate the plugin.
$('#myTable').DataTable( {
dom: 'lrtipM'
});
Usage
This plugin provides the following additional API calls:
Metadata
Store column specific metadata in the datatable. This is used by the filtering functions below, but can also be used to store arbitrary data related to the column as required. This data is state saved if state saving is enabled.
.column().meta()
// retrieve meta information for a column.column().meta(obj)
// set the metadata for a column to the specified object (replaces any existing metadata).column().meta(key, data)
// set thekey
property in the column metadata object todata
Numeric Range Filters
.column().range(min, max)
// numeric range filtering for a column. either min or max can benull
to enable one sided filtering.column().range()
// clear numeric range filters on this column
Date Range Filters (requires moment.js)
.column().dateRange(min, max)
// date range filtering for a column. either min or max can benull
to enable one sided filtering. Values can be strings (parsed via moment.js) or JS date objects.column().dateRange()
// clear date range filters on this column
Utility
.pick(attr1, attr2, ... attrN)
// similar to.pluck(),
but returns a new instance of the Datatables API with the result set being an array of objects with the specified keys. Intended to be used when chained after.data()
or.columns().data()
or similar api calls..pick([attr1, attr2, ... attrN])
// identical to above, but accepts the attributes in an array. this version will be used ifarguments.length===1
and the first argument is an array.