Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion types/tabulator-tables/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1315,7 +1315,7 @@ export interface ColumnDefinition extends ColumnLayout, CellCallbacks {
*
* You can set accessors on a per column basis using the accessor option in the column definition object.
*/
accessor?: CustomAccessor | undefined;
accessor?: CustomAccessor | undefined | "rownum";

/** Each accessor function has its own matching params option, for example accessorDownload has accessorDownloadParams. */
accessorParams?: CustomAccessorParams | undefined;
Expand Down Expand Up @@ -1648,6 +1648,7 @@ export type Formatter =
| "handle"
| "rowSelection"
| "responsiveCollapse"
| "toggle"
| ((cell: CellComponent, formatterParams: {}, onRendered: EmptyCallback) => string | HTMLElement);

export type FormatterParams =
Expand All @@ -1662,6 +1663,7 @@ export type FormatterParams =
| StarRatingParams
| RowSelectionParams
| JSONRecord
| ToggleSwitchParams
| ((cell: CellComponent) => {});

export type Editor =
Expand Down Expand Up @@ -1780,6 +1782,17 @@ export interface RowSelectionParams {
rowRange?: RowRangeLookup | undefined;
}

export interface ToggleSwitchParams {
size?: number | undefined;
max?: number | undefined;
onValue?: string | number | undefined;
offValue?: string | number | undefined;
onTruthy?: boolean | undefined;
onColor?: string | undefined;
offColor?: string | undefined;
clickable?: boolean | undefined;
}

export interface SharedEditorParams {
elementAttributes?: JSONRecord | undefined;

Expand Down
24 changes: 24 additions & 0 deletions types/tabulator-tables/tabulator-tables-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1718,3 +1718,27 @@ table.on("importError", function(err) {
table.on("importImported", function(data) {
// data - array of row data
});

table = new Tabulator("#example-table", {
columns: [
{
title: "First",
field: "rownum",
formatter: "rownum",
accessor: "rownum",
},
{
title: "Toggle",
field: "toggle",
formatter: "toggle",
editable: false,
formatterParams: {
onValue: "true",
offValue: "false",
onColor: "green",
offColor: "gray",
clickable: true,
},
},
],
});