@types/tabulator-tables
Version:
TypeScript definitions for tabulator-tables
906 lines (760 loc) • 178 kB
TypeScript
// cspell: ignore XLXS, alphanum, datetime, datetimediff, rownum, freetext, recalc, Monkhouse
export interface Options
extends
OptionsGeneral,
OptionsMenu,
OptionsHistory,
OptionsLocale,
OptionsDownload,
OptionsColumns,
OptionsRows,
OptionsData,
OptionsSorting,
OptionsFiltering,
OptionsRowGrouping,
OptionsPagination,
OptionsPersistentConfiguration,
OptionsClipboard,
OptionsDataTree,
OptionsDebug,
OptionsHTML,
OptionsSpreadsheet
{}
export interface OptionsDebug {
invalidOptionWarning?: boolean;
/** Enabled by default this will provide a console warning if you are trying to set an option on the table that does not exist. With the new optional modular structure this is particularly valuable as it will prompt you if you are trying to use an option for a module that has not been installed */
debugInvalidOptions?: boolean;
/** Enabled by default this will provide a console warning if you try and call a function on the table before it has been initialized. */
debugInitialization?: boolean;
/** The debugEventsExternal option will create a console log for every external event that is fired so you can gain an understanding of which events you should be binding to. */
debugEventsExternal?: boolean;
/** The debugEventsInternal option will create a console log for every internal event that is fired so you can gain an understanding of which events you should be subscribing to in your modules. */
debugEventsInternal?: boolean;
/** Disable component function warnings */
debugInvalidComponentFuncs?: boolean;
/** Disable deprecation warnings */
debugDeprecation?: boolean;
}
export interface OptionsDataTree {
/** To enable data trees in your table, set the dataTree property to true in your table constructor: */
dataTree?: boolean | undefined;
/** By default the toggle element will be inserted into the first column on the table. If you want the toggle element to be inserted in a different column you can pass the field name of the column to the dataTreeElementColumn setup option. */
dataTreeElementColumn?: boolean | string | undefined;
/** Show tree branch icon. */
dataTreeBranchElement?: boolean | string | undefined;
/** Tree level indent in pixels */
dataTreeChildIndent?: number | undefined;
/** By default Tabulator will look for child rows in the _children field of a row data object. You can change this to look in a different field using the dataTreeChildField property in your table constructor: */
dataTreeChildField?: string | undefined;
/**
* The toggle button that allows users to collapse and expand the column can be customized to meet your needs. There are two options, dataTreeExpandElement and dataTreeCollapseElement, that can be set to replace the default toggle elements with your own.
*
* Both options can take either an html string representing the contents of the toggle element
*/
dataTreeCollapseElement?: string | HTMLElement | boolean | undefined;
/** The toggle button that allows users to expand the column. */
dataTreeExpandElement?: string | HTMLElement | boolean | undefined;
/**
* By default all nodes on the tree will start collapsed, you can customize the initial expansion state of the tree using the dataTreeStartExpanded option.*
* This option can take one of three possible value types, either a boolean to indicate whether all nodes should start expanded or collapsed:
*/
dataTreeStartExpanded?: boolean | boolean[] | ((row: RowComponent, level: number) => boolean) | undefined;
/** Propagate selection events from parent rows to children. */
dataTreeSelectPropagate?: boolean | undefined;
dataTreeFilter?: boolean | undefined;
dataTreeSort?: boolean | undefined;
/**
* When you are using the dataTree option with your table, the column calculations will by default only use the data for the top level rows and will ignore any children.
* To include child rows in the column calculations set the dataTreeChildColumnCalcs option to true in the table constructor.
*/
dataTreeChildColumnCalcs?: boolean | undefined;
}
export interface OptionsClipboard {
/**
* You can enable clipboard functionality using the clipboard config option. It can take one of four possible values:
* true - enable clipboard copy and paste
* "copy" - enable only copy functionality
* "paste" - enable only paste functionality
* false - disable all clipboard functionality (default)
*/
clipboard?: boolean | "copy" | "paste" | undefined;
/** The clipboardCopyRowRange option takes a Row Range Lookup value and allows you to choose which rows are included in the clipboard output: */
clipboardCopyRowRange?: RowRangeLookup | undefined;
/** You can alter the finished output to the clipboard using the clipboardCopyFormatter callback. The callback function receives two arguments, the first is a string representing the type of content to be formatted (either "plain" or "html" depending on the type of data entering the clipboard). The second argument is the string that is about to be inserted into the clipboard. The function and should return a string that will be inserted into the clipboard. */
clipboardCopyFormatter?: "table" | ((type: "plain" | "html", output: string) => string) | undefined;
/** By default Tabulator will include the column header titles in any clipboard data, this can be turned off by passing a value of false to the clipboardCopyHeader property: */
clipboardCopyHeader?: boolean | undefined;
/**
* Tabulator has one built in paste parser, that is designed to take a table formatted text string from the clipboard and turn it into row data. it breaks the data into rows on a newline character \n and breaks the rows down to columns on a tab character \t.
* It will then attempt to work out which columns in the data correspond to columns in the table. It tries three different ways to achieve this. First it checks the values of all columns in the first row of data to see if they match the titles of columns in the table. If any of the columns don't match it then tries the same approach but with the column fields. If either of those options match, Tabulator will map those columns to the incoming data and import it into rows. If there is no match then Tabulator will assume the columns in the data are in the same order as the visible columns in the table and import them that way.
*
* The inbuilt parser will reject any clipboard data that does not contain at least one row and two columns, in that case the clipboardPasteError will be triggered.
*
* If you extend the clipboard module to add your own parser, you can set it to be used as default with the clipboardPasteParser property.
* Built-in parsers are "table" and "range".
*/
clipboardPasteParser?: string | ((clipboard: any) => any[]) | undefined;
/**
* Once the data has been parsed into row data, it will be passed to a paste action to be added to the table. There are three inbuilt paste actions:
*
* insert - Inserts data into the table using the addRows function (default)
* update - Updates data in the table using the updateOrAddData function
* replace - replaces all data in the table using the setData function
*/
clipboardPasteAction?: "insert" | "update" | "replace" | "range";
/**
* By default Tabulator will copy some of the tables styling along with the data to give a better visual appearance when pasted into other documents.
*
* If you want to only copy the un-styled data then you should set the clipboardCopyStyled option to false in the table options object:
*/
clipboardCopyStyled?: boolean | undefined;
/**
* By default Tabulator includes column headers, row groups and column calculations in the clipboard output.
*
* You can choose to remove column headers groups, row groups or column calculations from the output data by setting the values in the clipboardCopyConfig option in the table definition:
*/
clipboardCopyConfig?: AdditionalExportOptions | boolean | undefined;
/** When copying to clipboard you may want to apply a different group header from the one usually used in the table. You can now do this using the groupHeaderClipboard table option, which takes the same inputs as the standard groupHeader property. */
groupHeaderClipboard?:
| ((value: any, count: number, data: any, group: GroupComponent) => string)
| Array<(value: any, count: number, data: any) => string>
| undefined;
/** When the getHtml function is called you may want to apply a different group header from the one usually used in the table. You can now do this using the groupHeaderHtmlOutput table option, which takes the same inputs as the standard groupHeader property. */
groupHeaderHtmlOutput?:
| ((value: any, count: number, data: any, group: GroupComponent) => string)
| Array<(value: any, count: number, data: any) => string>
| undefined;
}
export interface OptionsPersistentConfiguration {
/** ID tag used to identify persistent storage information. */
persistenceID?: string | undefined;
/**
* Persistence information can either be stored in a cookie or in the localStorage object, you can use the persistenceMode to choose which. It can take three possible values:
*
* local - (string) Store the persistence information in the localStorage object
* cookie - (string) Store the persistence information in a cookie
* true - (boolean) check if localStorage is available and store persistence information, otherwise store in cookie (Default option)
*/
persistenceMode?: "local" | "cookie" | true | undefined;
/** Enable persistent storage of column layout information. */
persistentLayout?: boolean | undefined;
/** You can ensure the data sorting is stored for the next page load by setting the persistentSort option to true. */
persistentSort?: boolean | undefined;
/** You can ensure the data filtering is stored for the next page load by setting the persistentFilter option to true. */
persistentFilter?: boolean | undefined;
/** By setting the persistence property to true the table will persist the sort, filter, group (groupBy, groupStartOpen, groupHeader), pagination (paginationSize), and column (title, width, visibility, order) configuration of the table. */
persistence?: true | PersistenceOptions | undefined;
/** The persistenceWriterFunc function will receive three arguments, the persistance id of the table, the type of data to be written and an object or array representing the data */
persistenceWriterFunc?: ((id: string, type: keyof PersistenceOptions, data: any) => any) | undefined;
/** The persistenceReaderFunc function will receive two arguments, the persistance id of the table, and the type of data to be written. This function must synchronously return the data in the format in which it was passed to the persistenceWriterFunc function. It should return a value of false if no data was present. */
persistenceReaderFunc?: ((id: string, type: keyof PersistenceOptions) => any) | undefined;
}
export interface PersistenceOptions {
sort?: boolean | undefined;
filter?: boolean | undefined;
group?: boolean | PersistenceGroupOptions | undefined;
page?: boolean | PersistencePageOptions | undefined;
columns?: boolean | string[] | undefined;
headerFilter?: boolean | undefined;
}
export interface PersistenceGroupOptions {
groupBy?: boolean | undefined;
groupStartOpen?: boolean | undefined;
groupHeader?: boolean | undefined;
}
export interface PersistencePageOptions {
size?: boolean | undefined;
page?: boolean | undefined;
}
export interface OptionsPagination {
pagination?: boolean;
paginationMode?: SortMode;
/** Set the number of rows in each page. */
paginationSize?: number | undefined;
/**
* Setting this option to true will cause Tabulator to create a list of page size options, that are multiples of the current page size. In the example below, the list will have the values of 5, 10, 15 and 20.
*
* When using the page size selector like this, if you use the setPageSize function to set the page size to a value not in the list, the list will be regenerated using the new page size as the starting valuer
*/
paginationSizeSelector?: true | number[] | any[] | undefined;
/** By default the pagination controls are added to the footer of the table. If you wish the controls to be created in another element pass a DOM node or a CSS selector for that element to the paginationElement option. */
paginationElement?: HTMLElement | string | undefined;
/**
* Lookup list to link expected data fields from the server to their function
* ```typescript
* default: {
* "current_page": "current_page",
* "last_page": "last_page",
* "data": "data",
* }
* ```
*/
dataReceiveParams?: Record<string, string> | undefined;
/**
* Lookup list to link fields expected by the server to their function
* ```typescript
* default: {
* "page": "page",
* "size": "size",
* "sorters": "sorters",
* "filters": "filters",
* }
* ```
*/
dataSendParams?: Record<string, string> | undefined;
/**
* When using the addRow function on a paginated table, rows will be added relative to the current page (ie to the top or bottom of the current page), with overflowing rows being shifted onto the next page.
*
* If you would prefer rows to be added relative to the table (firs/last page) then you can use the paginationAddRow option. it can take one of two values:
*
* page - add rows relative to current page (default)
* table - add rows relative to the table
*/
paginationAddRow?: "table" | "page" | undefined;
/**
* You can choose to display a pagination counter in the bottom left of the footer that shows a summary of the current number of rows shown out of the total.
* If you want to have a fully customized counter, then you can pass a function to the paginationCounter option
*
* The formatter function accepts 5 arguments:
*
* pageSize - Number of rows shown per page
* currentRow - First visible row position
* currentPage - Current page
* totalRows - Total rows in table
* totalPages - Total pages in table
* The function must return the contents of the counter, either the text value of the counter, valid HTML or a DOM node
*/
paginationCounter?:
| "rows"
| "pages"
| ((
pageSize: number,
currentRow: number,
currentPage: number,
totalRows: number,
totalPages: number,
) => string | HTMLElement);
/**
* By default the counter will be displayed in the left of the table footer. If you would like it displayed in another element pass a DOM node or a CSS selector for that element.
*/
paginationCounterElement?: string | HTMLElement | undefined;
/** The number of pagination page buttons shown in the footer using the paginationButtonCount option. By default this has a value of 5. */
paginationButtonCount?: number | undefined;
/** Specify that a specific page should be loaded when the table first load. */
paginationInitialPage?: number | undefined;
}
export type GroupArg =
| string
| string[]
| ((data: any) => any)
| Array<string | ((data: any) => any)>;
export interface OptionsRowGrouping {
/** String/function to select field to group rows by */
groupBy?: GroupArg | undefined;
/**
* By default Tabulator will create groups for rows based on the values contained in the row data. if you want to explicitly define which field values groups should be created for at each level, you can use the groupValues option.
*
* This option takes an array of value arrays, each item in the first array should be a list of acceptable field values for groups at that level
*/
groupValues?: GroupValuesArg | undefined;
/** You can use the setGroupHeader function to change the header generation function for each group. This function has one argument and takes the same values as passed to the groupHeader setup option. */
groupHeader?:
| ((value: any, count: number, data: any, group: GroupComponent) => string)
| Array<(value: any, count: number, data: any) => string>
| undefined;
/** When printing you may want to apply a different group header from the one usually used in the table. You can now do this using the groupHeaderPrint table option, which takes the same inputs as the standard groupHeader property. */
groupHeaderPrint?:
| ((value: any, count: number, data: any, group: GroupComponent) => string)
| Array<(value: any, count: number, data: any) => string>
| undefined;
/**
* You can set the default open state of groups using the groupStartOpen property* * This can take one of three possible values:
*
* true - all groups start open (default value)
* false - all groups start closed
* function() - a callback to decide if a group should start open or closed
* Group Open Function
* If you want to decide on a group by group basis which should start open or closed then you can pass a function to the groupStartOpen property. This should return true if the group should start open or false if the group should start closed.
*/
groupStartOpen?:
| boolean
| boolean[]
| ((value: any, count: number, data: any, group: GroupComponent) => boolean)
| Array<boolean | ((value: any, count: number, data: any, group: GroupComponent) => boolean)>
| undefined;
/**
* By default Tabulator allows users to toggle a group open or closed by clicking on the arrow icon in the left of the group header. If you would prefer a different behavior you can use the groupToggleElement option to choose a different option:* * The option can take one of three values:
* arrow - toggle group on arrow element click
* header - toggle group on click anywhere on the group header element
* false - prevent clicking anywhere in the group toggling the group
*/
groupToggleElement?: "arrow" | "header" | false | undefined;
/** show/hide column calculations when group is closed. */
groupClosedShowCalcs?: boolean | undefined;
groupUpdateOnCellEdit?: boolean | undefined;
}
export interface Filter {
field: string;
type: FilterType;
value: any;
}
export interface FilterParams {
separator?: string | undefined;
matchAll?: boolean | undefined;
}
export type FilterFunction = (field: string, type: FilterType, value: any, filterParams?: FilterParams) => void;
export interface OptionsFiltering {
/** Array of filters to be applied on load. */
initialFilter?: Filter[] | undefined;
/** array of initial values for header filters. */
initialHeaderFilter?: Array<Pick<Filter, "field" | "value">> | undefined;
/** When using real time header filtering, Tabulator will wait 300 milliseconds after a keystroke before triggering the filter. You can customize this delay by using the headerFilterLiveFilterDelay table setup option. */
headerFilterLiveFilterDelay?: number | undefined;
}
export interface OptionsSorting {
/** Array of sorters to be applied on load. */
initialSort?: Sorter[] | undefined;
/** reverse the order that multiple sorters are applied to the table. */
sortOrderReverse?: boolean | undefined;
headerSortClickElement?: "header" | "icon";
}
export interface Sorter {
column: string;
dir: SortDirection;
}
export interface SorterFromTable {
/** The column component for the sorted column. */
column: ColumnComponent;
/** A string of the field name for the sorted column. */
field: string;
/** A string of either `asc` or `desc` indicating the direction of sort. */
dir: SortDirection;
}
export interface OptionsData {
/** A unique index value should be present for each row of data if you want to be able to programmatically alter that data at a later point, this should be either numeric or a string. By default Tabulator will look for this value in the id field for the data. If you wish to use a different field as the index, set this using the index option parameter. */
index?: number | string | undefined;
/** Array to hold data that should be loaded on table creation. */
data?: any[] | undefined;
importFormat?: "array" | "csv" | "json" | ((fileContents: string) => unknown[]);
/** By default Tabulator will read in the file as plain text, which is the format used by all the built in importers. If you need to read the file data in a different format then you can use the importReader option to instruct the file reader to read in the file in a different format. */
importReader?: "binary" | "buffer" | "text" | "url" | undefined;
autoTables?: boolean;
/** If you wish to retrieve your data from a remote source you can set the URL for the request in the ajaxURL option. */
ajaxURL?: string | undefined;
/** Parameters to be passed to remote Ajax data loading request. */
ajaxParams?: {} | undefined;
/** The HTTP request type for Ajax requests or config object for the request. */
ajaxConfig?: HttpMethod | AjaxConfig | undefined;
/**
* When using a request method other than "GET" Tabulator will send any parameters with a content type of form data. You can change the content type with the ajaxContentType option. This will ensure parameters are sent in the format you expect, with the correct headers. * * The ajaxContentType option can take one of two values:
* "form" - send parameters as form data (default option)
* "json" - send parameters as JSON encoded string
* If you want to use a custom content type then you can pass a content type formatter object into the ajaxContentType option. this object must have two properties, the headers property should contain all headers that should be sent with the request and the body property should contain a function that returns the body content of the request
*/
ajaxContentType?: "form" | "json" | AjaxContentType | undefined;
/**
* If you need more control over the url of the request that you can get from the ajaxURL and ajaxParams properties, the you can use the ajaxURLGenerator property to pass in a callback that will generate the URL for you.
*
* The callback should return a string representing the URL to be requested.
*/
ajaxURLGenerator?: ((url: string, config: any, params: any) => string) | undefined;
/** callback function to replace inbuilt ajax request functionality */
ajaxRequestFunc?: ((url: string, config: any, params: any) => Promise<any>) | undefined;
/** Send filter config to server instead of processing locally */
ajaxFiltering?: boolean | undefined;
/** Send sorter config to server instead of processing locally */
ajaxSorting?: boolean | undefined;
/**
* If you are loading a lot of data from a remote source into your table in one go, it can sometimes take a long time for the server to return the request, which can slow down the user experience.
*
* To speed things up in this situation Tabulator has a progressive load mode, this uses the pagination module to make a series of requests for part of the data set, one at a time, appending it to the table as the data arrives. This mode can be enable using the ajaxProgressiveLoad option. No pagination controls will be visible on screen, it just reuses the functionality of the pagination module to sequentially load the data.
*
* With this mode enabled, all of the settings outlined in the Ajax Documentation are still available
*
* There are two different progressive loading modes, to give you a choice of how data is loaded into the table.
*/
progressiveLoad?: "load" | "scroll" | undefined;
/** By default tabulator will make the requests to fill the table as quickly as possible. On some servers these repeats requests from the same client may trigger rate limiting or security systems. In this case you can use the ajaxProgressiveLoadDelay option to add a delay in milliseconds between each page request. */
progressiveLoadDelay?: number | undefined;
/** The ajaxProgressiveLoadScrollMargin property determines how close to the bottom of the table in pixels, the scroll bar must be before the next page worth of data is loaded, by default it is set to twice the height of the table. */
progressiveLoadScrollMargin?: number | undefined;
/** Show loader while data is loading, can also take a function that must return a boolean. */
ajaxLoader?: boolean | (() => boolean) | undefined;
/** html for loader element. */
ajaxLoaderLoading?: string | undefined;
/** html for the loader element in the event of an error. */
ajaxLoaderError?: string | undefined;
/** The ajaxRequesting callback is triggered when ever an ajax request is made. */
ajaxRequesting?: ((url: string, params: any) => boolean) | undefined;
/** The ajaxResponse callback is triggered when a successful ajax request has been made. This callback can also be used to modify the received data before it is parsed by the table. If you use this callback it must return the data to be parsed by Tabulator, otherwise no data will be rendered. */
ajaxResponse?: ((url: string, params: any, response: any) => any) | undefined;
dataLoader?: boolean;
dataLoaderLoading?: string | HTMLElement;
dataLoaderError?: string;
dataLoaderErrorTimeout?: number;
sortMode?: SortMode;
filterMode?: SortMode;
}
export type SortMode = "remote" | "local";
export interface AjaxContentType {
headers: JSONRecord;
body: (url: string, config: any, params: any) => any;
}
export type HttpMethod = "GET" | "POST";
export interface AjaxConfig {
method?: HttpMethod | undefined;
headers?: JSONRecord | undefined;
mode?: string | undefined;
credentials?: string | undefined;
}
export interface OptionsRows {
/**
* Tabulator also allows you to define a row level formatter using the rowFormatter option. this lets you alter each row of the table based on the data it contains.
* The function accepts one argument, the RowComponent for the row being formatted.
*/
rowFormatter?: ((row: RowComponent) => any) | undefined;
/** When printing you may want to apply a different formatter may want to apply a different formatter from the one usually used to format the row. */
rowFormatterPrint?: false | ((row: RowComponent) => any) | undefined;
/** When the getHtml function is called you may want to apply a different formatter may want to apply a different formatter from the one usually used to format the row */
rowFormatterHtmlOutput?: false | ((row: RowComponent) => any) | undefined;
/** When copying to the clipboard you may want to apply a different formatter may want to apply a different formatter from the one usually used to format the row. You can now do this using the rowFormatterClipboard table option, which takes the same inputs as the standard rowFormatter property. Passing a value of false into the formatter prevent the default row formatter from being run when the table is copied to the clipboard. */
rowFormatterClipboard?: false | ((row: RowComponent) => any) | undefined;
/** The position in the table for new rows to be added, "bottom" or "top". */
addRowPos?: "bottom" | "top" | undefined;
/**
* The selectableRows option can take one of a several values:
*
* - false - selectable rows are disabled
* - true - selectable rows are enabled, and you can select as many as you want
* - integer - any integer value, this sets the maximum number of rows that can be selected (when the maximum number of selected rows is exceeded, the first selected row will be deselected to allow the next row to be selected).
* - "highlight" (default) - rows have the same hover stylings as selectable rows but do not change state when clicked. This is great for when you want to show that a row is clickable but don't want it to be selectable.
*/
selectableRows?: boolean | number | "highlight" | undefined;
/**
* The selectableRange option can take one of a several values:
*
* - false - range selection is disabled
* - true - range selection is enabled, and you can add as many ranges as you want
* - integer - any integer value, this sets the maximum number of ranges that can be selected (when the maximum
* number of ranges is exceeded, the first selected range will be deselected to allow the next range to be selected).
*/
selectableRange?: boolean | number;
/**
* By default you can only select ranges by selecting cells on the table. If you would like to allow the user to
* select all cells in a column by clicking on the column header, then you can set the selectableRangeColumns option to true
*/
selectableRangeColumns?: boolean;
/**
* By default you can only select ranges by selecting cells on the table. If you would like to allow the user to
* select all cells in row by clicking on the row header, then you can set the selectableRangeColumns option to true
*/
selectableRangeRows?: boolean;
/**
* If you want the user to be able to clear the values for all cells in the active range by pressing the backspace
* or delete keys, then you can enable this behavior using the selectableRangeClearCells option:
*
* @example
* var table = new Tabulator("#example-table", {
* selectableRangeClearCells:true,
* });
*/
selectableRangeClearCells?: boolean;
/**
* By default the value of each cell in the range is set to undefined when this option is enabled and the user
* presses the backspace or delete keys. You can change the value the cells are set to using the
* selectableRangeClearCellsValue option
*
* @example
* var table = new Tabulator("#example-table", {
* selectableRangeClearCellsValue: "", //clear cells by setting value to an empty string
* });
*/
selectableRangeClearCellsValue?: unknown;
/**
* By default you can select a range of rows by holding down the shift key and click dragging over a number of rows
* to toggle the selected state state of all rows the cursor passes over.
*
* If you would prefer to select a range of row by clicking on the first row then holding down shift and clicking
* on the end row then you can achieve this by setting the selectableRowsRangeMode to click.
*
* @example
* var table = new Tabulator("#example-table", {
* selectableRowsRangeMode:"click",
* });
*/
selectableRowsRangeMode?: "click";
/**
* By default, row selection works on a rolling basis, if you set the selectableRows option to a numeric value then
* when you select past this number of rows, the first row to be selected will be deselected. If you want to
* disable this behavior and instead prevent selection of new rows once the limit is reached you can set the
* selectableRowsRollingSelection option to false.
*
* @example
* var table = new Tabulator("#example-table", {
* selectableRows: 5,
* selectableRowsRollingSelection:false, // disable rolling selection
* });
*/
selectableRowsRollingSelection?: boolean;
/**
* By default Tabulator will maintain selected rows when the table is filtered, sorted or paginated (but NOT when
* the setData function is used). If you want the selected rows to be cleared whenever the table view is updated
* then set the selectableRowsPersistence option to false.
*
* @example
* var table = new Tabulator("#example-table", {
* selectableRows: true,
* selectableRowsPersistence: false, // disable selection persistence
* });
*/
selectableRowsPersistence?: boolean;
/** You many want to exclude certain rows from being selected. The selectableRowsCheck options allows you to pass a function to check if the current row should be selectable, returning true will allow row selection, false will result in nothing happening. The function should accept a RowComponent as its first argument. */
selectableRowsCheck?: ((row: RowComponent) => boolean) | undefined;
/** To allow the user to move rows up and down the table, set the movableRows parameter in the options: */
movableRows?: boolean | undefined;
/** Tabulator also allows you to move rows between tables. To enable this you should supply either a valid CSS selector string a DOM node for the table or the Tabulator object for the table to the movableRowsConnectedTables option. if you want to connect to multiple tables then you can pass in an array of values to this option. */
movableRowsConnectedTables?: string | string[] | HTMLElement | HTMLElement[] | undefined;
/**
* The movableRowsSender option should be set on the sending table, and sets the action that should be taken after the row has been successfully dropped into the receiving table.
* There are several inbuilt sender functions:
*
* - false - do nothing(default)
* - delete - deletes the row from the table
* You can also pass a callback to the movableRowsSender option for custom sender functionality
*/
movableRowsSender?:
| false
| "delete"
| ((fromRow: RowComponent, toRow: RowComponent, toTable: Tabulator) => any)
| undefined;
/**
* The movableRowsReceiver option should be set on the receiving tables, and sets the action that should be taken when the row is dropped into the table.
* There are several inbuilt receiver functions:
*
* - insert - inserts row next to the row it was dropped on, if not dropped on a row it is added to the table (default)
* - add - adds row to the table
* - update - updates the row it is dropped on with the sent rows data
* - replace - replaces the row it is dropped on with the sent row
*/
movableRowsReceiver?:
| "insert"
| "add"
| "update"
| "replace"
| ((fromRow: RowComponent, toRow: RowComponent, fromTable: Tabulator) => any)
| undefined;
movableRowsConnectedElements?: string | HTMLElement | undefined;
/** You can allow the user to manually resize rows by dragging the top or bottom border of a row. To enable this functionality, set the resizableRows property to true. */
resizableRows?: boolean | undefined;
/**
* Allows the user to control the height of rows in the table by dragging the bottom border of the row.
* These guides will only appear on columns with the `resizable` option enabled in their column definition.
*/
resizableRowGuide?: boolean | undefined;
/**
* Allows the user to control the height of columns in the table by dragging the border of the column.
* These guides will only appear if the `resizableRows` option is enabled.
*/
resizableColumnGuide?: boolean | undefined;
/**
* The default ScrollTo position can be set using the scrollToRowPosition option. It can take one of four possible values:
*
* top - position row with its top edge at the top of the table (default)
* center - position row with its top edge in the center of the table
* bottom - position row with its bottom edge at the bottom of the table
* nearest - position row on the edge of the table it is closest to
*/
scrollToRowPosition?: ScrollToRowPosition | undefined;
/**
* The default option for triggering a ScrollTo on a visible element can be set using the scrollToRowIfVisible option. It can take a boolean value:
*
* true - scroll to row, even if it is visible (default)
* false - scroll to row, unless it is currently visible, then don't move
*/
scrollToRowIfVisible?: boolean | undefined;
/** Allows you to specify the behavior when the user tabs from the last editable cell on the last row of the table. */
tabEndNewRow?: boolean | JSONRecord | ((row: RowComponent) => any) | undefined;
frozenRowsField?: string;
/** Freeze rows of data */
frozenRows?: number | string[] | ((row: RowComponent) => boolean);
/**
* The editTriggerEvent option lets you choose which type of interaction event will trigger an edit on a cell.
*
* @example
* var table = new Tabulator("#example-table", {
* editTriggerEvent:"dblclick", // trigger edit on double click
* });
*
* This option can take one of three values:
*
* - focus - trigger edit when the cell has focus (default)
* - click - trigger edit on single click on cell
* - dblclick - trigger edit on double click on cell
*
* This option does not affect navigation behavior, cells edits will still be triggered when they are navigated to
* through arrow keys or tabs.
*/
editTriggerEvent?: "click" | "dblclick" | "focus";
}
export interface OptionsColumns {
/** The column definitions are provided to Tabulator in the columns property of the table constructor object and should take the format of an array of objects, with each object representing the configuration of one column. */
columns?: ColumnDefinition[] | undefined;
/** If you set the autoColumns option to true, every time data is loaded into the table through the data option or through the setData function, Tabulator will examine the first row of the data and build columns to match that data. */
autoColumns?: boolean | undefined | "full";
autoColumnsDefinitions?:
| ((columnDefinitions?: ColumnDefinition[]) => ColumnDefinition[])
| ColumnDefinition[]
| Record<string, Partial<ColumnDefinition>>
| undefined;
/** By default Tabulator will use the fitData layout mode, which will resize the tables columns to fit the data held in each column, unless you specify a width or minWidth in the column constructor. If the width of all columns exceeds the width of the containing element, a scroll bar will appear. */
layout?: "fitData" | "fitColumns" | "fitDataFill" | "fitDataStretch" | "fitDataTable" | undefined;
/**
* To keep the layout of the columns consistent, once the column widths have been set on the first data load (either from the data property in the constructor or the setData function) they will not be changed when new data is loaded.
*
* If you would prefer that the column widths adjust to the data each time you load it into the table you can set the layoutColumnsOnNewData property to true.
*/
layoutColumnsOnNewData?: boolean | undefined;
/**
* Responsive layout will automatically hide/show columns to fit the width of the Tabulator element. This allows for clean rendering of tables on smaller mobile devices, showing important data while avoiding horizontal scroll bars. You can enable responsive layouts using the responsiveLayout option.
*
* There are two responsive layout modes available:
*
* hide - hide columns that no longer fit in the table
* collapse - collapse columns that no longer fit on the table into a list under the row
*
* Hide Extra Columns
* By default, columns will be hidden from right to left as the width of the table decreases. You can choose exactly how columns are hidden using the responsive property in the column definition object.
*
* When responsive layout is enabled, all columns are given a default responsive value of 1. The higher you set this value the sooner that column will be hidden as the table width decreases. If two columns have the same responsive value then they are hidden from right to left (as defined in the column definition array, ignoring user moving of the columns). If you set the value to 0 then the column will never be hidden regardless of how narrow the table gets.
*/
responsiveLayout?: boolean | "hide" | "collapse" | undefined;
/** Collapsed lists are displayed to the user by default, if you would prefer they start closed so the user can open them you can use the responsiveLayoutCollapseStartOpen option. */
responsiveLayoutCollapseStartOpen?: boolean | undefined;
/**
* By default any formatter set on the column is applied to the value that will appear in the list. while this works for most formatters it can cause issues with the progress formatter which relies on being inside a cell.
*
* If you would like to disable column formatting in the collapsed list, you can use the responsiveLayoutCollapseUseFormatters option:
*/
responsiveLayoutCollapseUseFormatters?: boolean | undefined;
/**
* If you set the responsiveLayout option to collapse the values from hidden columns will be displayed in a title/value list under the row.
*
* In this mode an object containing the title of each hidden column and its value is generated and then used to generate a list displayed in a div .tabulator-responsive-collapse under the row data.
*
* The inbuilt collapse formatter creates a table to neatly display the hidden columns. If you would like to format the data in your own way you can use the responsiveLayoutCollapseFormatter, it take an object of the column values as an argument and must return the HTML content of the div.
*
* This function should return an empty string if there is no data to display.
*/
responsiveLayoutCollapseFormatter?: ((data: any[]) => any) | undefined;
/** To allow the user to move columns along the table, set the movableColumns parameter in the options: */
movableColumns?: boolean | undefined;
/** You can use the columnHeaderVertAlign option to set how the text in your column headers should be vertically. */
columnHeaderVertAlign?: VerticalAlign | undefined;
/**
* The default ScrollTo position can be set using the scrollToColumnPosition option. It can take one of three possible values:
*
* left - position column with its left edge at the left of the table (default)
* center - position column with its left edge in the center of the table
* right - position column with its right edge at the right of the table
*/
scrollToColumnPosition?: ScrollToColumnPosition | undefined;
/**
* The default option for triggering a ScrollTo on a visible element can be set using the scrollToColumnIfVisible option. It can take a boolean value:
*
* true - scroll to column, even if it is visible (default)
* false - scroll to column, unless it is currently visible, then don't move
*/
scrollToColumnIfVisible?: boolean | undefined;
/**
* By default column calculations are shown at the top and bottom of the table, unless row grouping is enabled, in which case they are shown at the top and bottom of each group.
*
* The columnCalcs option lets you decided where the calculations should be displayed, it can take one of four values:
*
* true - show calcs at top and bottom of the table, unless grouped, then show in groups (boolean, default)
* both - show calcs at top and bottom of the table and show in groups
* table - show calcs at top and bottom of the table only
* group - show calcs in groups only
*/
columnCalcs?: boolean | "both" | "table" | "group" | undefined;
/**
* If you need to use the . character as part of your field name, you can change the separator to any other character using the nestedFieldSeparator option
* Set to false to disable nested data parsing
*/
nestedFieldSeparator?: string | boolean | undefined;
/** multiple or single column sorting */
columnHeaderSortMulti?: boolean | undefined;
/** By setting the headerVisible option to false you can hide the column headers and present the table as a simple list if needed. */
headerVisible?: boolean | undefined;
/** The headerSort option can now be set in the table options to affect all columns as well as in column definitions. */
headerSort?: boolean | undefined;
headerSortElement?: string | undefined | ((column: ColumnComponent, dir: "asc" | "desc" | "none") => any);
columnDefaults?: Partial<ColumnDefinition>;
/** When the resizableColumnFit table definition option is set to true, when you resize a column, its adjacent column is resized in the opposite direction to keep the total width of the columns the same. */
resizableColumnFit?: boolean | undefined;
}
export interface OptionsGeneral {
/** Sets the height of the containing element, can be set to any valid height css value. If set to false (the default), the height of the table will resize to fit the table data. */
height?: string | number | false | undefined;
/** Can be set to any valid CSS value. By setting this you can allow your table to expand to fit the data, but not overflow its parent element. When there are too many rows to fit in the available space, the vertical scroll bar will be shown. This has the added benefit of improving load times on larger tables */
maxHeight?: string | number | undefined;
/** With a variable table height you can set the minimum height of the table either defined in the min-height CSS property for the element or set it using the minHeight option in the table constructor, this can be set to any valid CSS value. */
minHeight?: string | number | undefined;
renderVertical?: RenderMode;
renderHorizontal?: RenderMode;
rowHeight?: number;
/** Manually set the size of the virtual DOM buffer. */
renderVerticalBuffer?: boolean | number | undefined;
/** placeholder element to display on empty table. */
placeholder?: string | HTMLElement | ((this: Tabulator | TabulatorFull) => string) | undefined;
placeholderHeaderFilter?: string | HTMLElement | ((this: Tabulator | TabulatorFull) => string) | undefined;
/** Footer element to display for the table. */
footerElement?: string | HTMLElement | undefined;
/** Keybinding configuration object. */
keybindings?: false | KeyBinding | undefined;
/**
* The reactivity systems allow Tabulator to watch arrays and objects passed into the table for changes and then automatically update the table.
*
* This approach means you no longer need to worry about calling a number of different functions on the table to make changes, you simply update the array or object you originally passed into the table and Tabulator will take care of the rest.
*
* You can enable reactive data by setting the reactiveData option to true in the table constructor, and then passing your data array to the data option.
*
* Once the table is built any changes to the array will automatically be replicated to the table without needing to call any functions on the table itself
*/
reactiveData?: boolean | undefined;
// Not listed in options--------------------
/** Tabulator will automatically attempt to redraw the data contained in the table if the containing element for the table is resized. To disable this functionality, set the autoResize property to false. */
autoResize?: boolean | undefined;
/** Setting the invalidOptionWarnings option to false will disable console warning messages for invalid properties in the table constructor and column definition object. */
invalidOptionWarnings?: boolean | undefined;
/**
* There are now three different validation modes available to customize the validation experience:
*
* blocking - if a user enters an invalid value while editing, they are blocked from leaving the cell until a valid value is entered (default)
*
* highlight - if a user enters an invalid value, then the edit will complete as usual and they are allowed to exit the cell but a highlight is applied to the cell using the tabulator-validation-fail class
*
* manual - no validation is automatically performed on edit, but it can be triggered by calling the validate function on the table or any Component Object
*/
validationMode?: "blocking" | "highlight" | "manual" | undefined;
textDirection?: TextDirection | undefined;
/**
* Sometimes it can be useful to add a visual header to the start of a row.
* The `rowHeader` option allows you to define a column definition for a stylized header column at the start of the row.
*
* This can be great for adding row number, movable row handles or row selections, and keeps the controls visually separated from the table data.
*/
rowHeader?: boolean | {
formatter?: string;
field?: string;
headerSort?: boolean;
hozAlign?: ColumnDefinitionAlign;
headerHozAlign?: ColumnDefinitionAlign;
resizable?: boolean;
frozen?: boolean;
titleFormatter?: string;
cellClick?: (e: MouseEvent, cell: CellComponent) => void;
minWidth?: number;
width?: number;
rowHandle?: boolean;
} | undefined;
/*