Skip to content

Commit 2605740

Browse files
authored
🤖 Merge PR DefinitelyTyped#72442 Update headerMenu type definition by @Parjak39
1 parent be25068 commit 2605740

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

types/tabulator-tables/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1432,7 +1432,7 @@ export interface ColumnDefinition extends ColumnLayout, CellCallbacks {
14321432
/** You can add a menu to any column by passing an array of menu items to the headerMenu option in that columns definition. */
14331433
headerMenu?:
14341434
| Array<MenuObject<ColumnComponent> | MenuSeparator>
1435-
| (() => Array<MenuObject<ColumnComponent> | MenuSeparator>)
1435+
| ((e: MouseEvent, component: ColumnComponent) => Array<MenuObject<ColumnComponent> | MenuSeparator>)
14361436
| undefined;
14371437

14381438
/** The headerMenuIcon option will accept one of three types of value. You can pass in a string for the HTML contents of the button. Or you can pass the DOM node for the button. Though be careful not to pass the same node to multiple columns or you may run into issues. Or you can define a function that is called when the column header is rendered that should return either an HTML string or the contents of the element. This function is passed the column component as its first argument. */

types/tabulator-tables/tabulator-tables-tests.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1781,3 +1781,16 @@ table = new Tabulator("#test-selectableRowsCheck", {
17811781
table.selectRow([1, 2, 3]);
17821782
const selectedRows = table.getSelectedRows();
17831783
console.log("Number of selected rows:", selectedRows.length); // Should be 2 (only rows with age >= 18)
1784+
1785+
const headerMenuFunc = function(_e: MouseEvent, component: ColumnComponent) {
1786+
return [{
1787+
label: "Test",
1788+
}];
1789+
}
1790+
1791+
table = new Tabulator("#test-selectableRowsCheck", {
1792+
columns: [
1793+
{ title: "ID", field: "id" },
1794+
{ title: "Name", field: "name", headerMenu: headerMenuFunc },
1795+
],
1796+
});

0 commit comments

Comments
 (0)