// Type definitions for jquery.dynatable v0.3.1
// Project: http://www.dynatable.com/
// Definitions by: François Massart
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
///
interface JQuery {
/**
* @constructor
*/
dynatable: JQueryDynatable.Dynatable;
}
/** Static members of jQuery (those on $ and jQuery themselves) */
interface JQueryStatic {
/**
* Global dynatable plugin setting defaults
*
* @param options The configuration options to be set globally
*/
dynatableSetup(options: JQueryDynatable.Options): void;
}
declare namespace JQueryDynatable {
interface Features {
/**
* Enable the pagination feature
*
* @default true
*/
paginate?: boolean;
/**
* Enable the sorting feature
*
* @default true
*/
sort?: boolean;
/**
* Enable the pushState feature
* Used to update the page URL parameters and cache the query result for the browser's forward- and back-buttons
*
* @default true
*/
pushState?: boolean;
/**
* Enable the search feature
*
* @default true
*/
search?: boolean;
/**
* Enable the recordCount feature
* When pagination is enabled, dynatable will also show the currently displayed records and the total number of records
*
* @default true
*/
recordCount?: boolean;
/**
* Enable the perPageSelect feature
* The perPageSelect will insert a form control filled with the options from `perPageOptions`
*
* @default true
*/
perPageSelect?: boolean;
}
interface Column {
index: number;
label: string;
/**
* Determined by the `data-dynatable-column` or using the `defaultColumnIdStyle`
*
* @example
* // Using the `defaultColumnIdStyle` of `camelCase`
* // `
Favorite Music
` would be translated into the id `favoriteMusic`
*/
id: string;
/**
* Function that returns the cell data to be written inside the cell
*
* @param record A data object representing the current line of data
* @return The data for the current cell
*
* @example
* function exampleAttributeWriter(record) {
* return record[this.id];
* };
*/
attributeWriter: (record: any) => any;
/**
* Function that interprets the cell html data in order to convert it into data
*
* @param cell A html node of the target cell
* @param record A data object representing the current line of data
* @return the html content for the current cell
*
* @example
* function exampleAttributeReader(cell, record) {
* return $(cell).html();
* };
*/
attributeReader: (cell: Element, record: any) => string;
/** List of ids for sorting, generated by the plugin, can be tweaked by using `data-dynatable-sorts` */
sorts: Array;
hidden: boolean;
/**
* Detected internally by dynatable.
* Possible values are:
*
* @enum('left', 'right', 'center', 'justify', 'initial', 'inherit')
*/
textAlign: string;
}
interface Table {
/**
* By default, dynatable converts headings to JSON attribute names using:
*
* @enum('camelCase', 'trimDash', 'dashed', 'underscore', 'lowercase')
* @default 'camelCase'
* @see http://www.dynatable.com/#converting-attribute-names
*
* @example
* // Given the html `
Favorite Music
` column header
* // `camelCase` would translate it to id `favoriteMusic`
* // `trimDash` would translate it to id `Favorite-Music`
* // `dashed` would translate it to id `favorite-music`
* // `underscore` would translate it to id `favorite_music`
* // `lowercase` would translate it to id `favorite music`
*/
defaultColumnIdStyle?: string;
/** Generated internally by the plugin, will be reset by the DomColumns at init */
columns?: Array;
/**
* Selector used by dynatable in order to find the table header row
*
* @default 'thead tr'
*/
headRowSelector?: string;
/**
* Selector used by dynatable in order to find the table body rows
*
* @default 'tbody tr'
*/
bodyRowSelector?: string;
/**
* Optional classname that can be added by dynatable to the header cells
*
* @default null
*/
headRowClass?: string;
}
interface Inputs {
/**
* Allows you to provide an array of jQuery objects which point to our filter inputs.
* The inputs musts have a name attribute value matching a columnId in order to work.
* Input values must strictly match the data from the cell...
* Searching for "Lux" won't show "Luxembourg" event if it starts if the same letters!
*
* @default null
* @see http://www.dynatable.com/#querying
*
* @example
* $('#search-year')
*/
queries?: JQuery;
/**
* @todo Find out how this `inputs.sorts` setting is useful + show an example
* @default null
* @see http://www.dynatable.com/#sorting
*/
sorts?: any;
/**
* Allows you to define the accepted modifier keys to trigger a multisort action
*
* @default ['ctrlKey', 'shiftKey', 'metaKey']
* @see https://en.wikipedia.org/wiki/Modifier_key
*/
multisort?: Array;
/**
* @todo Find out how this `inputs.page` setting is useful + show an example
* @default null
*/
page?: any;
/**
* The events attached to the search/filtering inputs elements
*
* @default 'blur change'
*/
queryEvent?: string;
/**
* The jQuery object pointing to a target where to insert the recordCount html
*
* @default null
*
* @example
* $('#chart-status-text')
*/
recordCountTarget?: JQuery;
/**
* Determines where the recordCount is inserted
*
* @enum('before', 'after')
* @default 'after'
* @see http://api.jquery.com/category/manipulation/dom-insertion-outside/
*/
recordCountPlacement?: string;
/**
* The target inside next to which the pagination block will be inserted (before or after).
* You can use a selector string, an Element or a JQuery.
*
* @default null
*/
paginationLinkTarget?: string|Element|JQuery;
/**
* Determines where the pagination links are inserted
*
* @enum('before', 'after')
* @default 'after'
* @see http://api.jquery.com/category/manipulation/dom-insertion-outside/
*/
paginationLinkPlacement?: string;
/**
* The classname to be injected on the `
` containing the pagination
*
* @default 'dynatable-pagination-links'
*/
paginationClass?: string;
/**
* The classname to be injected on every pagination link
*
* @default 'dynatable-page-link'
*/
paginationLinkClass?: string;
/**
* The classname to be injected on the previous page link
*
* @default 'dynatable-page-prev'
*/
paginationPrevClass?: string;
/**
* The classname to be injected on the next page link
*
* @default 'dynatable-page-next'
*/
paginationNextClass?: string;
/**
* The classname to be injected on the current page link
*
* @default 'dynatable-active-page'
*/
paginationActiveClass?: string;
/**
* The classname to be injected on the disabled page links
*
* @default 'dynatable-disabled-page'
*/
paginationDisabledClass?: string;
/**
* Text content for the previous page link
*
* @default 'Previous'
*/
paginationPrev?: string;
/**
* Text content for the next page link
*
* @default 'Next'
*/
paginationNext?: string;
/**
* Define the number of page number links shown inside the pagination
*
* @default [1,2,2,1]
*/
paginationGap?: Array;
/**
* The target next to which the search block will be inserted (before or after).
* You can use a selector string, an Element or a JQuery.
*
* @default null
*/
searchTarget?: string|Element|JQuery;
/**
* Determines where the search field is inserted
*
* @enum('before', 'after')
* @default 'before'
* @see http://api.jquery.com/category/manipulation/dom-insertion-outside/
*/
searchPlacement?: string;
/**
* Text preceding the search field
*
* @default 'Search: '
*/
searchText?: string;
/**
* The target next to which the per page pagination block will be inserted (before or after).
* You can use a selector string, an Element or a jQuery object.
*
* @default null
*/
perPageTarget?: string|Element|JQuery;
/**
* Determines where the perPage menu is inserted
*
* @enum('before', 'after')
* @default 'before'
* @see http://api.jquery.com/category/manipulation/dom-insertion-outside/
*/
perPagePlacement?: string;
/**
* Text content preceding the items per page