Interactive table generation JavaScript library with sorting, filtering, editing, formatting, and extensive customization capabilities
—
Comprehensive data loading, manipulation, and synchronization capabilities for dynamic table content with support for local and remote data sources.
Core methods for loading data into tables with support for various data sources and formats.
/**
* Load data into table, replacing existing data
* @param data - Data array, URL string, or false to clear
* @param params - Additional parameters for AJAX requests
* @param config - Configuration options for data loading
* @returns Promise resolving when data is loaded
*/
setData(data: any[] | string | false, params?: any, config?: any): Promise<void>;
/**
* Replace data while maintaining current sort order and position
* @param data - New data to replace existing data
* @param params - Additional parameters for AJAX requests
* @param config - Configuration options for data loading
* @returns Promise resolving when data is replaced
*/
replaceData(data: any[] | string | false, params?: any, config?: any): Promise<void>;
/**
* Clear all data from table
*/
clearData(): void;
/**
* Get current table data
* @param active - If true, only return visible rows (after filtering)
* @returns Array of row data objects
*/
getData(active?: boolean): any[];
/**
* Get count of data rows
* @param active - If true, only count visible rows (after filtering)
* @returns Number of rows
*/
getDataCount(active?: boolean): number;Usage Examples:
// Load local data
await table.setData([
{ id: 1, name: "Alice", age: 25 },
{ id: 2, name: "Bob", age: 30 }
]);
// Load from API endpoint
await table.setData("/api/users", { department: "engineering" });
// Replace data maintaining current view
await table.replaceData(updatedData);
// Get all data vs filtered data
const allData = table.getData(); // All rows
const visibleData = table.getData(true); // Only visible after filtersMethods for adding and updating multiple rows efficiently.
/**
* Add multiple rows to table
* @param data - Array of row data objects to add
* @param pos - Position to add rows (true=top, false=bottom, number=index)
* @param index - Index value to add rows relative to
* @returns Promise resolving to array of added RowComponents
*/
addData(data: any[], pos?: boolean | number, index?: any): Promise<RowComponent[]>;
/**
* Update multiple existing rows based on index field
* @param data - Array of row data objects with updates
* @returns Promise resolving when all updates complete
*/
updateData(data: any[]): Promise<void>;
/**
* Update existing rows or add new ones if they don't exist
* @param data - Array of row data objects
* @returns Promise resolving to array of affected RowComponents
*/
updateOrAddData(data: any[]): Promise<RowComponent[]>;Precise control over individual row lifecycle and data.
/**
* Add single row to table
* @param data - Row data object
* @param pos - Position to add (true=top, false=bottom, number=index)
* @param index - Index value to add row relative to
* @returns Promise resolving to new RowComponent
*/
addRow(data: any, pos?: boolean | number, index?: any): Promise<RowComponent>;
/**
* Update existing row data
* @param index - Row index/key to update
* @param data - New data object for row
* @returns Promise resolving to updated RowComponent
*/
updateRow(index: any, data: any): Promise<RowComponent>;
/**
* Update existing row or add new one if it doesn't exist
* @param index - Row index/key to update or create
* @param data - Row data object
* @returns Promise resolving to RowComponent
*/
updateOrAddRow(index: any, data: any): Promise<RowComponent>;
/**
* Delete one or more rows from table
* @param index - Single index or array of indices to delete
* @returns Promise resolving when deletion completes
*/
deleteRow(index: any | any[]): Promise<void>;Usage Examples:
// Add single row at top
const newRow = await table.addRow({ id: 5, name: "Eve", age: 27 }, true);
// Update specific row
await table.updateRow(3, { name: "Charlie Updated", age: 29 });
// Bulk operations
await table.addData([
{ id: 6, name: "Frank", age: 35 },
{ id: 7, name: "Grace", age: 32 }
], false); // Add to bottom
// Update or create multiple rows
await table.updateOrAddData([
{ id: 1, name: "Alice Updated" }, // Updates existing
{ id: 8, name: "Henry", age: 40 } // Creates new
]);
// Delete multiple rows
await table.deleteRow([2, 4, 6]);Methods for finding and accessing specific rows within the table.
/**
* Get row component by index value
* @param index - Row index/key to find
* @returns RowComponent or false if not found
*/
getRow(index: any): RowComponent | false;
/**
* Get row component by position in table
* @param position - Zero-based position in current row order
* @returns RowComponent or false if invalid position
*/
getRowFromPosition(position: number): RowComponent | false;
/**
* Get all row components
* @param active - If true, only return visible rows (after filtering)
* @returns Array of RowComponents
*/
getRows(active?: boolean): RowComponent[];
/**
* Get position of row in current table order
* @param index - Row index/key to find position of
* @returns Zero-based position or false if not found
*/
getRowPosition(index: any): number | false;Control row ordering and position within the table display.
/**
* Move row to new position
* @param from - Index of row to move
* @param to - Target index or row to move to
* @param after - If true, move after target; if false, move before
*/
moveRow(from: any, to: any, after?: boolean): void;
/**
* Scroll table to show specific row
* @param index - Row index to scroll to
* @param position - Position in viewport ("top", "center", "bottom", "nearest")
* @param ifVisible - Only scroll if row is not currently visible
* @returns Promise resolving when scroll completes
*/
scrollToRow(index: any, position?: string, ifVisible?: boolean): Promise<void>;Methods for selecting and managing row selection state.
/**
* Select specific rows
* @param indexes - Single index or array of indices to select
*/
selectRow(indexes: any | any[]): void;
/**
* Deselect specific rows
* @param indexes - Single index or array of indices to deselect
*/
deselectRow(indexes: any | any[]): void;
/**
* Toggle selection state of specific rows
* @param indexes - Single index or array of indices to toggle
*/
toggleSelectRow(indexes: any | any[]): void;
/**
* Get all currently selected row components
* @returns Array of selected RowComponents
*/
getSelectedRows(): RowComponent[];
/**
* Get data from all currently selected rows
* @returns Array of selected row data objects
*/
getSelectedData(): any[];Usage Examples:
// Row selection operations
table.selectRow([1, 3, 5]); // Select multiple rows
table.selectRow(2); // Select single row
table.deselectRow(1); // Deselect specific row
table.toggleSelectRow([2, 4]); // Toggle selection
// Get selection information
const selectedRows = table.getSelectedRows();
const selectedData = table.getSelectedData();
console.log(`${selectedRows.length} rows selected`);
// Work with selected data
selectedData.forEach(data => {
console.log("Selected user:", data.name);
});
// Find and manipulate specific rows
const row = table.getRow(5);
if (row) {
console.log("Row data:", row.getData());
row.update({ status: "active" });
}
// Get all visible rows after filtering
const visibleRows = table.getRows(true);
console.log(`${visibleRows.length} rows visible`);
// Move row to different position
table.moveRow(1, 5, true); // Move row 1 after row 5
// Navigation and scrolling
await table.scrollToRow(10, "center"); // Center row 10 in view
const position = table.getRowPosition(3); // Get current position of row 3interface AjaxConfig {
/** URL for data requests */
ajaxURL?: string;
/** Parameters to send with AJAX requests */
ajaxParams?: any;
/** Axios/fetch configuration object */
ajaxConfig?: any;
/** Content type for requests */
ajaxContentType?: string;
/** Custom request function */
ajaxRequestFunc?: (url: string, config: any, params: any) => Promise<any>;
/** Response processing function */
ajaxResponse?: (url: string, params: any, response: any) => any;
}interface LocalDataConfig {
/** Enable reactive data binding */
reactiveData?: boolean;
/** Transform data before processing */
dataTransformed?: (data: any[]) => any[];
/** Custom data loading logic */
dataLoader?: boolean | ((data: any) => Promise<any[]>);
/** Process data after loading */
dataLoaded?: (data: any[]) => void;
}Usage Examples:
// Remote data with custom processing
const remoteTable = new Tabulator("#remote-table", {
ajaxURL: "/api/users",
ajaxParams: { active: true },
ajaxResponse: function(url, params, response) {
return response.data.users; // Extract users from nested response
},
columns: columnDefinitions
});
// Reactive local data
let reactiveData = [
{ id: 1, name: "Alice", status: "active" }
];
const reactiveTable = new Tabulator("#reactive-table", {
data: reactiveData,
reactiveData: true, // Auto-update when data array changes
columns: columnDefinitions
});
// Modify data - table updates automatically
reactiveData.push({ id: 2, name: "Bob", status: "inactive" });
reactiveData[0].status = "inactive";Install with Tessl CLI
npx tessl i tessl/npm-tabulator-tables