### Install Tabulator via Bower
Source: https://github.com/tabulator-tables/tabulator/blob/master/README.md
Use the Bower package manager to install Tabulator. Run this command in your project directory.
```bash
bower install tabulator --save
```
--------------------------------
### Install Tabulator via NPM
Source: https://github.com/tabulator-tables/tabulator/blob/master/README.md
Use the NPM package manager to install Tabulator. Run this command in your project directory.
```bash
npm install tabulator-tables --save
```
--------------------------------
### Build the library from the repo root
Source: https://github.com/tabulator-tables/tabulator/blob/master/examples/README.md
Run these commands from the repository root to install dependencies and build the library, generating dist/js/tabulator.js and dist/css/tabulator.css. Required before opening the examples.
```bash
npm install # first time only
npm run build # generates dist/js/tabulator.js and dist/css/tabulator.css
```
--------------------------------
### Run Tabulator tests
Source: https://github.com/tabulator-tables/tabulator/blob/master/README.md
Commands to run unit and end-to-end tests. Build the project before running E2E tests.
```bash
# Unit test
npm run test:unit
# E2E test
npm run build # Make sure to build the project first
npx playwright test # Run the tests
# or
npm run test:e2e
# Run all tests
npm run test
```
--------------------------------
### Include Tabulator library and CSS
Source: https://github.com/tabulator-tables/tabulator/blob/master/README.md
Add the Tabulator CSS and JavaScript files to your HTML page. This is the first step in setting up Tabulator.
```html
```
--------------------------------
### Include Tabulator from UNPKG CDN
Source: https://github.com/tabulator-tables/tabulator/blob/master/README.md
Load Tabulator directly from the UNPKG CDN servers. Use these lines instead of the locally hosted versions.
```html
```
--------------------------------
### Popup positioning example with size definitions and table setup
Source: https://github.com/tabulator-tables/tabulator/blob/master/examples/11-popup-positioning.html
Defines popup sizes and builds a Tabulator table with context and header popups. The popup contents are generated dynamically based on the selected size, and the table is configured with popupContainer option to host popups inside the table element or on document.body.
```javascript
// Each popup is a fixed-size block, so the placement maths is easy to follow.
// "tall" is deliberately taller than any normal viewport, which is what makes
// Tabulator cap its height rather than let it run off the bottom.
var SIZES = {
small: { width: 180, height: 120, lines: 6 },
wide: { width: 900, height: 120, lines: 6 },
tall: { width: 240, height: 1500, lines: 60 },
};
var sizeSelect = document.getElementById("popup-size");
var containerSelect = document.getElementById("popup-container");
var readout = document.getElementById("readout");
// Popup contents can be a function, so the size is read at open time and the
// dropdown takes effect without rebuilding the table.
function popupContents() {
var size = SIZES[sizeSelect.value];
var el = document.createElement("div");
el.className = "demo-popup";
el.style.width = size.width + "px";
el.style.height = size.height + "px";
for (var i = 1; i <= size.lines; i++) {
var line = document.createElement("div");
line.textContent = "Popup line " + i;
el.appendChild(line);
}
return el;
}
var tabledata = [];
for (var i = 1; i <= 60; i++) {
var row = {
id: i,
name: "Person " + i,
dept: i % 2 ? "Engineering" : "Sales",
age: 20 + (i % 40)
};
// Filler columns, so the table is wider than any viewport and there are
// always cells hard against the left and right edges.
for (var n = 1; n <= 6; n++) {
row["note" + n] = "note " + n + "-" + i;
}
tabledata.push(row);
}
function columns() {
var cols = [
{ title: "ID", field: "id", sorter: "number", contextPopup: popupContents },
// headerPopup adds a clickable icon in the header; the popup is anchored to
// that icon rather than to the mouse.
{ title: "Name", field: "name", sorter: "string", contextPopup: popupContents, headerPopup: popupContents, headerPopupIcon: "⋮" },
{ title: "Department", field: "dept", sorter: "string", contextPopup: popupContents },
{ title: "Age", field: "age", sorter: "number", hozAlign: "right", contextPopup: popupContents },
];
for (var n = 1; n <= 6; n++) {
cols.push({ title: "Note " + n, field: "note" + n, contextPopup: popupContents });
}
return cols;
}
var table, nested;
function build() {
if (table) {
table.destroy();
}
if (nested) {
nested.destroy();
}
// popupContainer: true hosts popups inside the table element; false (the
// default) hosts them on document.body.
table = new Tabulator("#example-table", {
data: tabledata,
columns: columns(),
layout: "fitColumns",
height: "1300px",
popupContainer: containerSelect.value === "table",
rowContextPopup: popupContents,
});
// This one always uses the scrollable div, to contrast with the main table.
nested = new Tabulator("#nested-table", {
data: tabledata.slice(0, 20),
columns: columns(),
layout: "fitColumns",
height: "260px",
popupContainer: "#scroll-box",
rowContextPopup: popupContents,
});
}
// Only the container choice needs a rebuild - popupContents() reads the size
// at open time, so the size dropdown takes effect on the next popup.
containerSelect.addEventListener("change", build);
document.getElementById("go-corner").addEventListener("click", function () {
window.scrollTo(document.body.scrollWidth, document.body.scrollHeight);
});
document.getElementById("go-origin").addEventListener("click", function () {
window.scrollTo(0, 0);
});
// Live readout of the scroll position, the viewport, and where the open popup
// ended up. "OFF SCREEN" means the placement failed to keep it in view.
function updateReadout() {
var popup = document.querySelector(".tabulator-popup-container");
var parts = [
"scroll " + Math.round(window.scrollX) + "," + Math.round(window.scrollY),
"viewport " + document.documentElement.clientWidth + "×" + document.documentElement.clientHeight,
];
if (popup) {
var box = popup.getBoundingClientRect();
var onScreen = box.left >= -0.5 && box.top >= -0.5 && box.right <= document.documentElement.clientWidth + 0.5 && box.bottom <= document.documentElement.clientHeight + 0.5;
parts.push(
"popup " + Math.round(box.left) + "," + Math.round(box.top) + " → " + Math.round(box.right) + "," + Math.round(box.bottom),
onScreen ? "ON SCREEN" : "OFF SCREEN"
);
}
readout.textContent = parts.join(" | ");
}
window.addEventListener("scroll", updateReadout);
setInterval(updateReadout, 200);
build();
updateReadout();
```
--------------------------------
### Initialize a Tabulator table
Source: https://github.com/tabulator-tables/tabulator/blob/master/README.md
Create a new Tabulator instance by passing the container element's selector and an empty options object. This turns the element into an interactive table.
```js
var table = new Tabulator("#example-table", {});
```
--------------------------------
### Open the gallery in a browser
Source: https://github.com/tabulator-tables/tabulator/blob/master/examples/README.md
Open examples/index.html directly in a browser (macOS or Linux) or serve the folder with a static server. Works off the file:// protocol since all data is inline.
```bash
open examples/index.html # macOS
xdg-open examples/index.html # Linux
```
```bash
npx serve examples
```
--------------------------------
### Tabulator table setup with editors and validators
Source: https://github.com/tabulator-tables/tabulator/blob/master/examples/04-editing.html
Creates a Tabulator table with various editors (input, list, number, star, date, tickCross) and validators. The data array defines sample rows. The table is bound to the element with id 'example-table'.
```javascript
var tabledata = [
{ id: 1, name: "Oli Bob", location: "United Kingdom", progress: 12, gender: "male", rating: 1, dob: "2005-08-14", driver: true },
{ id: 2, name: "Mary May", location: "Germany", progress: 90, gender: "female", rating: 4, dob: "1989-02-01", driver: false },
{ id: 3, name: "Chris L.", location: "France", progress: 42, gender: "male", rating: 0, dob: "1980-11-23", driver: true },
{ id: 4, name: "Margret M.",location: "Sweden", progress: 16, gender: "female", rating: 5, dob: "1998-06-30", driver: true },
];
var logEl = document.getElementById("log");
var table = new Tabulator("#example-table", {
data: tabledata,
layout: "fitColumns",
columns: [
// Plain text input with a "required" validator.
{ title: "Name", field: "name", editor: "input", validator: "required" },
// List editor that auto-populates its options from existing column values.
{ title: "Location", field: "location", editor: "list", editorParams: { autocomplete: true, allowEmpty: true, listOnEmpty: true, valuesLookup: true } },
// Number editor constrained to 0-100, shown as a progress bar.
{ title: "Progress", field: "progress", sorter: "number", formatter: "progress", editor: "number", editorParams: { min: 0, max: 100 }, validator: ["min:0", "max:100"] },
// List editor with an explicit value map.
{ title: "Gender", field: "gender", editor: "list", editorParams: { values: { male: "Male", female: "Female", unknown: "Unknown" } } },
// Star editor — click a star to set the rating.
{ title: "Rating", field: "rating", formatter: "star", hozAlign: "center", width: 130, editor: "star" },
// Built-in date editor using a native (no external libs).
{ title: "Date Of Birth", field: "dob", sorter: "date", hozAlign: "center", editor: "date" },
// Boolean toggled with a tick/cross editor.
{ title: "Driver", field: "driver", hozAlign: "center", formatter: "tickCross", editor: "tickCross" },
],
});
```
```javascript
// In Tabulator 6 you bind event callbacks with table.on(...).
// cellEdited fires after a cell is successfully edited.
table.on("cellEdited", function (cell) {
var msg = cell.getField() + " (row " + cell.getRow().getIndex() + "): " + JSON.stringify(cell.getOldValue()) + " → " + JSON.stringify(cell.getValue());
logEl.textContent = msg + "\n" + logEl.textContent;
});
```
--------------------------------
### Create a container element for the table
Source: https://github.com/tabulator-tables/tabulator/blob/master/README.md
Define an HTML element that will hold the Tabulator table. This element is referenced when initializing the table.
```html
```
--------------------------------
### movableRowsSendingStart
Source: https://github.com/tabulator-tables/tabulator/blob/master/_autodocs/events.md
Triggered when the table starts sending rows to another table. Provides the connection tables.
```APIDOC
## Event: movableRowsSendingStart
### Description
Triggered when the table starts sending rows to another table.
### Payload
- `connectionTables` (array) - An array of table instances that are connected for row movement.
```
--------------------------------
### ColumnComponent usage example
Source: https://github.com/tabulator-tables/tabulator/blob/master/_autodocs/api-reference/ColumnComponent.md
Demonstrates obtaining a column component via table.getColumn(), reading its properties, updating its definition, toggling visibility, and using header filter methods when the filter module is installed.
```javascript
const col = table.getColumn("name");
console.log(col.getField(), col.getDefinition(), col.getWidth());
col.setWidth(200);
await col.updateDefinition({ title: "Full Name", hozAlign: "left" });
col.hide();
console.log(col.isVisible()); // false
col.show();
// header filter (filter module installed)
col.setHeaderFilterValue("Ali");
console.log(col.getHeaderFilterValue()); // "Ali"
```
--------------------------------
### Full Demo Table Data and Configuration
Source: https://github.com/tabulator-tables/tabulator/blob/master/examples/10-full-demo.html
Defines the table data array and initializes a Tabulator instance with features like persistence, row selection, grouping, and various column definitions. Includes a comment about tracking the next id for adding rows.
```javascript
var tabledata = [
{ id: 1, name: "Oli Bob", dept: "Engineering", progress: 12, rating: 1, revenue: 12000, active: true, dob: "2005-08-14" },
{ id: 2, name: "Mary May", dept: "Sales", progress: 90, rating: 4, revenue: 48000, active: false, dob: "1989-02-01" },
{ id: 3, name: "Chris L.", dept: "Engineering", progress: 42, rating: 0, revenue: 9000, active: true, dob: "1980-11-23" },
{ id: 4, name: "Brendon P.", dept: "Marketing", progress: 100,rating: 1, revenue: 21000, active: true, dob: "1992-04-18" },
{ id: 5, name: "Margret M.", dept: "Sales", progress: 16, rating: 5, revenue: 33500, active: false, dob: "1998-06-30" },
{ id: 6, name: "Van Ng", dept: "Engineering", progress: 70, rating: 3, revenue: 27000, active: true, dob: "1975-09-12" },
];
// Track the next id so "Add row" produces unique keys.
var nextId = tabledata.length + 1;
var table = new Tabulator("#example-table", {
data: tabledata,
layout: "fitColumns",
index: "id",
// Persist sort, filter, group and column layout across reloads.
persistence: true,
persistenceID: "tabulator-examples-full-demo",
selectableRows: true,
groupBy: "dept",
groupStartOpen: true,
columns: [
{ formatter: "rowSelection", titleFormatter: "rowSelection", hozAlign: "center", headerSort: false, width: 45, cellClick: function (e, cell) { cell.getRow().toggleSelect(); } },
{ title: "Name", field: "name", editor: "input", validator: "required", headerFilter: "input", widthGrow: 2 },
{ title: "Department", field: "dept", headerFilter: "list", headerFilterParams: { values: ["Engineering", "Sales", "Marketing"], clearable: true }, editor: "list", editorParams: { values: ["Engineering", "Sales", "Marketing"] } },
{ title: "Progress", field: "progress", sorter: "number", formatter: "progress", formatterParams: { min: 0, max: 100 }, editor: "number", editorParams: { min: 0, max: 100 }, validator: ["min:0", "max:100"], bottomCalc: "avg", bottomCalcParams: { precision: 0 } },
{ title: "Rating", field: "rating", formatter: "star", hozAlign: "center", width: 120, editor: "star" },
{ title: "Revenue", field: "revenue", sorter: "number", hozAlign: "right", formatter: "money", formatterParams: { symbol: "$", precision: 0, thousand: "," }, editor: "number", bottomCalc: "sum", bottomCalcFormatter: "money", bottomCalcFormatterParams: { symbol: "$", precision: 0, thousand: "," } },
{ title: "Active", field: "active", hozAlign: "center", formatter: "tickCross", editor: "tickCross", headerFilter: "tickCross", headerFilterParams: { tristate: true } },
{ title: "DOB", field: "dob", sorter: "date", hozAlign: "center", editor: "date" },
// Per-row delete button.
{ title: "", width: 60, hozAlign: "center", headerSort: false, formatter: function () { return "🗑"; }, cellClick: function (e, cell) { cell.getRow().delete(); } },
],
});
```
--------------------------------
### Usage examples for TabulatorFull and plain Tabulator
Source: https://github.com/tabulator-tables/tabulator/blob/master/_autodocs/api-reference/TabulatorFull.md
Shows how to use TabulatorFull in ESM/bundlers and via UMD script tag, plus the equivalent plain Tabulator with manual module registration.
```javascript
// ESM / bundlers
import { TabulatorFull as Tabulator } from "tabulator-tables";
// UMD script tag: global `Tabulator` is TabulatorFull
const table = new Tabulator("#example-table", {
layout: "fitColumns",
movableColumns: true,
selectableRows: true,
filterMode: "local",
columns: [{ title: "Name", field: "name", sorter: "string", headerFilter: "input" }],
});
// plain-Tabulator equivalent requires manual registration:
import { Tabulator, AjaxModule, EditModule } from "tabulator-tables";
Tabulator.registerModule(AjaxModule, EditModule);
const minimal = new Tabulator("#other-table", { ajaxURL: "/data" });
```
--------------------------------
### module(key)
Source: https://github.com/tabulator-tables/tabulator/blob/master/_autodocs/api-reference/Tabulator.md
Returns the module instance for the given key. Logs 'Tabulator module not installed: ' when missing.
```APIDOC
## module(key)
### Description
Returns the module instance for the given key. Logs 'Tabulator module not installed: ' when missing.
### Method
module
### Parameters
- **key** (string) - Required - Module key.
### Returns
`module instance`
```
--------------------------------
### Initialize Tabulator with dataTree and columns
Source: https://github.com/tabulator-tables/tabulator/blob/master/examples/09-tree-data.html
Creates a Tabulator table with tree mode enabled (`dataTree: true`), starting collapsed (`dataTreeStartExpanded: false`). The size column uses `bottomCalc: "sum"` to total across the entire tree.
```javascript
var table = new Tabulator("#example-table", {
data: tabledata,
layout: "fitColumns",
dataTree: true, // enable tree mode
dataTreeStartExpanded: false, // start collapsed
columns: [
{ title: "Name", field: "name", sorter: "string", widthGrow: 3 }, // toggle shows on first column
{ title: "Type", field: "type", sorter: "string" },
{ title: "Size (KB)", field: "size", sorter: "number", hozAlign: "right", bottomCalc: "sum" }, // sum spans the entire tree
],
});
```
--------------------------------
### movableRowsReceivingStart
Source: https://github.com/tabulator-tables/tabulator/blob/master/_autodocs/events.md
Triggered when the table starts receiving rows from another table. Provides the row and the source table.
```APIDOC
## Event: movableRowsReceivingStart
### Description
Triggered when the table starts receiving rows from another table.
### Payload
- `row` (RowComponent) - The row being received.
- `table` (Tabulator) - The source table instance.
```
--------------------------------
### Event Handlers for Add, Delete, Download, and Reset
Source: https://github.com/tabulator-tables/tabulator/blob/master/examples/10-full-demo.html
Adds event listeners to buttons for adding a row, deleting selected rows, downloading data in CSV/JSON/HTML formats, and resetting the saved layout by clearing localStorage and reloading.
```javascript
document.getElementById("add-row").addEventListener("click", function () {
table.addRow({ id: nextId++, name: "New Person", dept: "Engineering", progress: 0, rating: 0, revenue: 0, active: true, dob: "2000-01-01" }, true);
});
document.getElementById("clear-selected").addEventListener("click", function () {
table.getSelectedRows().forEach(function (row) {
row.delete();
});
});
document.getElementById("dl-csv").addEventListener("click", function () {
table.download("csv", "tabulator-data.csv");
});
document.getElementById("dl-json").addEventListener("click", function () {
table.download("json", "tabulator-data.json");
});
document.getElementById("dl-html").addEventListener("click", function () {
table.download("html", "tabulator-data.html", { style: true });
});
document.getElementById("reset").addEventListener("click", function () {
table.clearHistory && table.clearHistory();
// Wipe the persisted layout and reload to start fresh.
["sort", "filter", "group", "page", "columns"].forEach(function (type) {
localStorage.removeItem("tabulator-examples-full-demo-" + type);
});
location.reload();
});
```
--------------------------------
### Example: Using CalcComponent with columnCalcs
Source: https://github.com/tabulator-tables/tabulator/blob/master/_autodocs/api-reference/CalcComponent.md
Shows how to create a Tabulator table with a bottomCalc, retrieve calc results, and access a calc row's component from the display pipeline.
```javascript
// requires columnCalcs + Accessor/plain values
const table = new TabulatorFull("#t", {
data: [{ id: 1, cost: 10 }, { id: 2, cost: 20 }],
columns: [{ title: "Cost", field: "cost", bottomCalc: "sum" }],
});
const results = table.getCalcResults();
console.log(results); // { top: {}, bottom: { cost: "30" } }
// a calc row's component from the display pipeline
const rows = table.getRows("display");
const calcRow = rows.find((r) => r.getType && r._getSelf().type === "calc");
if (calcRow) {
console.log(calcRow.getData()); // { cost: "30" }
console.log(calcRow.getCell("cost").getValue());
}
```
--------------------------------
### Client-side pagination with Tabulator
Source: https://github.com/tabulator-tables/tabulator/blob/master/examples/05-pagination.html
Generates 200 rows of sample data and configures a Tabulator table with local pagination, a page size selector, and a row counter. Use the page controls at the bottom, change the page size with the selector, and watch the row counter.
```javascript
// Generate 200 rows of sample data so paging is meaningful.
var firstNames = ["Oli", "Mary", "Chris", "Brendon", "Margret", "Van", "Duc", "Anita", "Sam", "Priya"];
var depts = ["Engineering", "Sales", "Marketing", "Support", "Finance"];
var tabledata = [];
for (var i = 1; i <= 200; i++) {
tabledata.push({
id: i,
name: firstNames[i % firstNames.length] + " #" + i,
dept: depts[i % depts.length],
age: 18 + (i * 7) % 45,
score: (i * 37) % 100,
});
}
var table = new Tabulator("#example-table", {
data: tabledata,
layout: "fitColumns",
pagination: "local", // page the in-memory data
paginationSize: 10, // rows per page
paginationSizeSelector: [10, 25, 50, 100], // let the user change page size
paginationCounter: "rows", // "Showing X-Y of Z rows"
columns: [
{ title: "ID", field: "id", width: 70, sorter: "number" },
{ title: "Name", field: "name", sorter: "string" },
{ title: "Department", field: "dept", sorter: "string" },
{ title: "Age", field: "age", sorter: "number", hozAlign: "right" },
{ title: "Score", field: "score", sorter: "number", hozAlign: "right", formatter: "progress", formatterParams: { min: 0, max: 100 } },
],
});
```
--------------------------------
### Create Tabulator table with sorting and filtering
Source: https://github.com/tabulator-tables/tabulator/blob/master/examples/03-sorting-filtering.html
Initializes a Tabulator instance on #example-table with data, fitColumns layout, and columns configured with sorters and header filters (input, number, list, tickCross).
```javascript
var table = new Tabulator("#example-table", {
data: tabledata,
layout: "fitColumns",
columns: [
{ title: "Name", field: "name", sorter: "string", headerFilter: "input" }, // free-text header filter
{ title: "Age", field: "age", sorter: "number", hozAlign: "right", headerFilter: "number", headerFilterPlaceholder: "≥", headerFilterFunc: ">=" },
{ title: "Department", field: "dept", sorter: "string", headerFilter: "list", // dropdown header filter
headerFilterParams: { values: ["Engineering", "Sales", "Marketing"], clearable: true } },
{ title: "Active", field: "active", hozAlign: "center", formatter: "tickCross", headerFilter: "tickCross", headerFilterParams: { tristate: true } },
],
});
```
--------------------------------
### Tabulator table with input editors and required validator
Source: https://github.com/tabulator-tables/tabulator/blob/master/test/e2e/bootstrap5-edit.html
Creates a Tabulator table with two columns, 'Name' and 'Remarks', both using the 'input' editor. The 'Remarks' column includes a 'required' validator. The table uses 'fitData' layout and is bound to the element with id 'example-table'.
```javascript
window.testTable = new Tabulator("#example-table", {
data: [
{ name: "Alice", remarks: "Excellent performance" },
{ name: "Bob", remarks: "Needs improvement" },
],
layout: "fitData",
columns: [
{ title: "Name", field: "name", editor: "input" },
{ title: "Remarks", field: "remarks", editor: "input", validator: "required" },
],
});
```
--------------------------------
### CellComponent usage example
Source: https://github.com/tabulator-tables/tabulator/blob/master/_autodocs/api-reference/CellComponent.md
Shows how to obtain a CellComponent and use its methods: getValue, getField, setValue with and without mutation, restoreOldValue, edit, cancelEdit, and validate.
```javascript
const cell = table.getRow(1).getCell("name");
console.log(cell.getValue(), cell.getField());
cell.setValue("New Name"); // runs mutators/events
cell.setValue(JSON.stringify({a: 1}), false); // raw set, no mutation chain
cell.restoreOldValue();
// editing (edit module installed)
if (cell.edit()) {
// editor is now open; commit from the editor success callback
cell.cancelEdit();
}
// validation (validate module installed)
console.log(cell.validate()); // true or array of failed validators
```
--------------------------------
### Example: using GroupComponent methods
Source: https://github.com/tabulator-tables/tabulator/blob/master/_autodocs/api-reference/GroupComponent.md
Shows how to obtain groups via table.getGroups(), iterate over them to log field, key, and row count, toggle visibility, and use isVisible, getParentGroup, and scrollTo. Requires the groupRows module (groupBy option).
```javascript
// requires groupRows module
const table = new TabulatorFull("#t", {
data: [{ id: 1, dept: "Engineering", name: "Ada" }, { id: 2, dept: "Engineering", name: "Grace" }],
groupBy: "dept",
columns: [{ title: "Name", field: "name" }],
});
const groups = table.getGroups();
groups.forEach((group) => {
console.log(group.getField(), group.getKey(), group.getRows().length);
group.toggle(); // collapse/expand
});
const eng = groups[0];
console.log(eng.isVisible(), eng.getParentGroup());
await eng.scrollTo("top");
```
--------------------------------
### setStartBound
Source: https://github.com/tabulator-tables/tabulator/blob/master/_autodocs/api-reference/RangeComponent.md
Sets the start bound of the range and relayouts.
```APIDOC
## setStartBound(start)
### Description
Sets the start bound of the range and relayouts.
### Method
`setStartBound(start)`
### Parameters
- `start` (CellComponent) - Required - The start cell.
### Notes
- Runs `destroyedGuard` first and no-ops if the range has been destroyed.
```
--------------------------------
### Responsive collapse with fitDataFill and responsive priorities
Source: https://github.com/tabulator-tables/tabulator/blob/master/examples/08-frozen-responsive.html
Creates a Tabulator table that fits the container width using fitDataFill and responsiveLayout: 'collapse'. Columns with higher responsive values hide first into an expandable sub-row when space runs out; the rowHeader uses the responsiveCollapse formatter to provide the toggle. The Name column with responsive: 0 is never hidden.
```JavaScript
// 2) Responsive collapse. Columns have real widths and use `fitDataFill`, so
// when they don't all fit, the highest `responsive` values are hidden first
// into a collapsed sub-row (revealed via the row-header toggle).
new Tabulator("#responsive-table", {
data: tabledata,
layout: "fitDataFill",
responsiveLayout: "collapse",
// row header holds the expand/collapse toggle for the hidden fields
rowHeader: {
formatter: "responsiveCollapse",
width: 30,
minWidth: 30,
hozAlign: "center",
resizable: false,
headerSort: false
},
columns: [
{ title: "Name", field: "name", width: 160, responsive: 0 }, // 0 = never hide
{ title: "Department", field: "dept", width: 140, responsive: 1 },
{ title: "Salary", field: "salary", width: 110, hozAlign: "right", responsive: 1, formatter: "money", formatterParams: money },
{ title: "Title", field: "title", width: 150, responsive: 3 },
{ title: "City", field: "city", width: 120, responsive: 3 },
{ title: "Country", field: "country", width: 150, responsive: 2 },
{ title: "Email", field: "email", width: 200, responsive: 4 },
{ title: "Phone", field: "phone", width: 130, responsive: 5 }, // hidden first
{ title: "Started", field: "started", width: 130, sorter: "date", responsive: 5 },
],
});
```
--------------------------------
### Full column definition example
Source: https://github.com/tabulator-tables/tabulator/blob/master/_autodocs/types.md
Shows a frequently combined column definition using base keys and module options. Includes sorter, formatter, editor, header filter, mutator, accessor, calculations, layout, styling, and nested columns.
```javascript
{
title: "Name",
field: "name",
sorter: "string", sorterParams: {},
formatter: "plaintext", formatterParams: {},
editor: "input", editorParams: {}, editable: true,
headerFilter: "input", headerFilterFunc: "like",
mutator: (value, data, type, params, component) => value,
accessor: (value, data, type, params, component) => value,
topCalc: "sum", bottomCalc: "avg", bottomCalcParams: { precision: 2 },
frozen: false, resizable: true, visible: true,
width: 200, minWidth: 40, maxWidth: 400,
cssClass: "my-col", hozAlign: "center", vertAlign: "middle",
headerHozAlign: "center", headerVertical: false, headerWordWrap: false,
editableTitle: false, tooltip: true, responsive: 0,
columns: [ /* nested group columns */ ],
}
```
--------------------------------
### RangeComponent usage example
Source: https://github.com/tabulator-tables/tabulator/blob/master/_autodocs/api-reference/RangeComponent.md
Shows how to obtain and manipulate a range via the public API. Requires the selectableRange option. Demonstrates getBounds, getRows, getColumns, setBounds, fill, setData, and remove; after remove, subsequent calls are guarded.
```javascript
// requires selectableRange option
const table = new TabulatorFull("#t", { selectableRange: true, data: [...], columns: [...] });
const [range] = table.getRanges();
const bounds = range.getBounds();
console.log(range.getRows().length, range.getColumns().length);
const start = range.getCells()[0];
range.setBounds(start, table.getRow(5).getCell("name"));
range.fill("n/a"); // apply to all cells
range.setData([["a", "b"], ["c", "d"]]);
range.remove(); // subsequent calls are guarded
```
--------------------------------
### Define table data for formatter example
Source: https://github.com/tabulator-tables/tabulator/blob/master/examples/02-formatters.html
Array of objects with fields used by the formatters: progress (0-100), rating (0-5), paid (boolean), salary (number), color (hex), and site (URL).
```javascript
var tabledata = [
{ id: 1, name: "Oli Bob", progress: 12, rating: 1, paid: true, salary: 32000, color: "#d9534f", site: "https://tabulator.info" },
{ id: 2, name: "Mary May", progress: 90, rating: 4, paid: false, salary: 41250, color: "#5cb85c", site: "https://tabulator.info" },
{ id: 3, name: "Chris L.", progress: 42, rating: 0, paid: true, salary: 28900, color: "#f0ad4e", site: "https://tabulator.info" },
{ id: 4, name: "Brendon P.",progress: 100,rating: 1, paid: false, salary: 56000, color: "#5bc0de", site: "https://tabulator.info" },
{ id: 5, name: "Margret M.",progress: 16, rating: 5, paid: true, salary: 38500, color: "#9b59b6", site: "https://tabulator.info" },
];
```
--------------------------------
### modExists(plugin, required)
Source: https://github.com/tabulator-tables/tabulator/blob/master/_autodocs/api-reference/Tabulator.md
Checks if a module exists. If required and missing, logs 'Tabulator Module Not Installed'. Returns boolean.
```APIDOC
## modExists(plugin, required)
### Description
Checks if a module exists. If required and missing, logs 'Tabulator Module Not Installed'. Returns boolean.
### Method
modExists
### Parameters
- **plugin** (string) - Required - Module name.
- **required** (boolean) - Optional - If true, logs error when missing.
### Returns
`boolean`
```
--------------------------------
### Edit log placeholder
Source: https://github.com/tabulator-tables/tabulator/blob/master/examples/04-editing.html
Placeholder text displayed in the edit log before any edits are made.
```text
No edits yet — change a cell above.
```
--------------------------------
### Grouping and Column Calculations with Tabulator
Source: https://github.com/tabulator-tables/tabulator/blob/master/examples/06-grouping-calculations.html
Sets up a Tabulator table with data grouped by department, showing average age and total/max revenue per group and overall. The group header displays the department name and person count, and the table uses fitColumns layout with sorting and money formatting.
```javascript
var tabledata = [
{ id: 1, name: "Oli Bob", dept: "Engineering", age: 28, revenue: 12000 },
{ id: 2, name: "Mary May", dept: "Sales", age: 41, revenue: 48000 },
{ id: 3, name: "Chris L.", dept: "Engineering", age: 22, revenue: 9000 },
{ id: 4, name: "Brendon P.", dept: "Marketing", age: 35, revenue: 21000 },
{ id: 5, name: "Margret M.", dept: "Sales", age: 26, revenue: 33500 },
{ id: 6, name: "Van Ng", dept: "Engineering", age: 51, revenue: 27000 },
{ id: 7, name: "Duc Ng", dept: "Marketing", age: 29, revenue: 15500 },
{ id: 8, name: "Anita Bath", dept: "Sales", age: 33, revenue: 52000 },
];
var table = new Tabulator("#example-table", {
data: tabledata,
layout: "fitColumns",
groupBy: "dept", // group rows by this field
groupStartOpen: true,
// Custom group header showing the department and its row count.
groupHeader: function (value, count) {
return value + " (" + count + " " + (count === 1 ? "person" : "people") + ")";
},
columns: [
{ title: "Name", field: "name", sorter: "string" },
{ title: "Department", field: "dept", sorter: "string" },
{ title: "Age", field: "age", sorter: "number", hozAlign: "right", bottomCalc: "avg", bottomCalcParams: { precision: 1 } }, // average age
{ title: "Revenue", field: "revenue", sorter: "number", hozAlign: "right", formatter: "money", formatterParams: { symbol: "$", precision: 0, thousand: "," }, topCalc: "max", // highest in group/table
topCalcFormatter: "money", topCalcFormatterParams: { symbol: "$", precision: 0, thousand: "," }, bottomCalc: "sum", // total
bottomCalcFormatter: "money", bottomCalcFormatterParams: { symbol: "$", precision: 0, thousand: "," } },
],
});
```
--------------------------------
### Sort Module
Source: https://github.com/tabulator-tables/tabulator/blob/master/_autodocs/api-reference/ModuleLibrary.md
Provides sorting functionality for the table. Users can set, get, and clear sorters.
```APIDOC
## Sort Module
### Description
Provides sorting functionality for the table. Users can set, get, and clear sorters.
### Registered Table Functions
#### `setSort(sortList, dir)`
Sets the sorters on the table.
#### `getSorters()`
Returns the current sorters.
#### `clearSort()`
Clears all sorters.
### Static Sorters
See [types.md](../types.md).
### Table Options
- `sortMode` (default `"local"`)
- `initialSort`
- `columnHeaderSortMulti` (default `true`)
- `sortOrderReverse`
- `headerSortElement`
- `headerSortClickElement`
### Column Options
- `sorter`
- `sorterParams`
- `headerSort` (default `true`)
- `headerSortStartingDir`
- `headerSortTristate`
```
--------------------------------
### Basic Tabulator table with inline data and column definitions
Source: https://github.com/tabulator-tables/tabulator/blob/master/examples/01-basic-table.html
Creates a Tabulator table with an array of plain objects as data, column definitions mapping titles to fields, fit-to-width layout, and click-to-sort columns using the sorter option.
```javascript
// Inline sample data — an array of plain objects.
var tabledata = [
{ id: 1, name: "Oli Bob", age: 12, country: "United Kingdom", rating: 1 },
{ id: 2, name: "Mary May", age: 1, country: "Germany", rating: 2 },
{ id: 3, name: "Christine Lobowski", age: 42, country: "France", rating: 0 },
{ id: 4, name: "Brendon Philips", age: 125, country: "USA", rating: 1 },
{ id: 5, name: "Margret Marmajuke", age: 16, country: "Sweden", rating: 5 },
{ id: 6, name: "Van Ng", age: 37, country: "Vietnam", rating: 4 },
{ id: 7, name: "Duc Ng", age: 37, country: "Vietnam", rating: 3 },
];
// Create the table. Each column maps a header title to a data field.
// `sorter` tells Tabulator how to compare values when a header is clicked.
var table = new Tabulator("#example-table", {
data: tabledata,
layout: "fitColumns", // columns expand to fill the available width
columns: [
{ title: "ID", field: "id", width: 70, sorter: "number" },
{ title: "Name", field: "name", sorter: "string" },
{ title: "Age", field: "age", sorter: "number", hozAlign: "right" },
{ title: "Country", field: "country", sorter: "string" },
{ title: "Rating", field: "rating", sorter: "number", hozAlign: "right" },
],
});
```
--------------------------------
### SheetComponent usage example
Source: https://github.com/tabulator-tables/tabulator/blob/master/_autodocs/api-reference/SheetComponent.md
Requires the spreadsheet option (set to 'tabs' or true). Creates a TabulatorFull instance with spreadsheet enabled, retrieves the sheet components, and demonstrates setting title, data, activating a sheet, adding a new sheet, and removing it.
```javascript
// requires spreadsheet option ("tabs" or true)
const table = new TabulatorFull("#t", {
spreadsheet: true,
spreadsheetRows: 20,
spreadsheetColumns: 10,
});
const sheets = table.getSheets(); // SheetComponent[]
const s = sheets[0];
console.log(s.getTitle(), s.getKey(), s.getData());
s.setTitle("Budget");
s.setData([[1, 2], [3, 4]]);
s.active();
const added = table.addSheet({ title: "Q2" });
table.removeSheet(added);
```
--------------------------------
### RowComponent usage example
Source: https://github.com/tabulator-tables/tabulator/blob/master/_autodocs/api-reference/RowComponent.md
Demonstrates common RowComponent operations: retrieving a row by index, updating data, accessing cells, using module functions like select/deselect, and scrolling. Requires the selectRow module for row.select() and row.isSelected().
```javascript
const row = table.getRow(1); // by index (options.index field)
row.update({ name: "Alice Smith" })
.then(() => console.log(row.getData()));
row.getCell("name").setValue("Alice B.");
row.getCells().forEach(c => console.log(c.getField(), c.getValue()));
// module functions (when selectRow module installed)
row.select();
if (row.isSelected()) { row.deselect(); }
// navigation
await row.scrollTo("center", true);
```
--------------------------------
### Row selection with checkbox column and API buttons
Source: https://github.com/tabulator-tables/tabulator/blob/master/examples/07-selection.html
Creates a Tabulator table with a checkbox column for row selection, a header checkbox to toggle all rows, and buttons to select/deselect all and log selected data. Uses the rowSelectionChanged event to update a count element. Requires an HTML element with id 'example-table' and buttons with ids 'select-all', 'deselect-all', and 'log-selected'.
```javascript
var tabledata = [
{ id: 1, name: "Oli Bob", dept: "Engineering", age: 28 },
{ id: 2, name: "Mary May", dept: "Sales", age: 41 },
{ id: 3, name: "Chris L.", dept: "Engineering", age: 22 },
{ id: 4, name: "Brendon P.", dept: "Marketing", age: 35 },
{ id: 5, name: "Margret M.", dept: "Sales", age: 26 },
{ id: 6, name: "Van Ng", dept: "Engineering", age: 51 },
];
var countEl = document.getElementById("count");
var logEl = document.getElementById("log");
var table = new Tabulator("#example-table", {
data: tabledata,
layout: "fitColumns",
selectableRows: true, // allow row selection
columns: [
// Checkbox column: cell tickbox selects the row, header tickbox toggles all.
{ formatter: "rowSelection", titleFormatter: "rowSelection", hozAlign: "center", headerSort: false, width: 50, cellClick: function (e, cell) { cell.getRow().toggleSelect(); } },
{ title: "Name", field: "name", sorter: "string" },
{ title: "Department", field: "dept", sorter: "string" },
{ title: "Age", field: "age", sorter: "number", hozAlign: "right" },
],
});
// In Tabulator 6 you bind event callbacks with table.on(...).
// Keep the on-page summary in sync with selection state.
table.on("rowSelectionChanged", function (data, rows) {
countEl.textContent = data.length;
});
document.getElementById("select-all").addEventListener("click", function () {
table.selectRow();
});
document.getElementById("deselect-all").addEventListener("click", function () {
table.deselectRow();
});
document.getElementById("log-selected").addEventListener("click", function () {
logEl.textContent = JSON.stringify(table.getSelectedData(), null, 2);
});
```
--------------------------------
### show()
Source: https://github.com/tabulator-tables/tabulator/blob/master/_autodocs/api-reference/ColumnComponent.md
Shows the column and its group if needed.
```APIDOC
## show()
### Description
Shows the column and its group if needed. For grouped columns, recurses into all child columns.
### Method
`show()`
### Returns
`undefined`
```
--------------------------------
### _getSelf()
Source: https://github.com/tabulator-tables/tabulator/blob/master/_autodocs/api-reference/ColumnComponent.md
Returns the internal Column object.
```APIDOC
## _getSelf()
### Description
Returns the internal Column object.
### Method
`_getSelf()`
### Returns
internal `Column`
```