Skip to content

Commit 5e43537

Browse files
authored
🤖 Merge PR DefinitelyTyped#72378 tabulator-tables - selectableCheck is deprecated by selectableRowsCheck by @danielHin
1 parent 1c626e7 commit 5e43537

File tree

2 files changed

+26
-30
lines changed

2 files changed

+26
-30
lines changed

‎types/tabulator-tables/index.d.ts‎

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -514,16 +514,6 @@ export interface OptionsRows {
514514
/** The position in the table for new rows to be added, "bottom" or "top". */
515515
addRowPos?: "bottom" | "top" | undefined;
516516

517-
/**
518-
* The selectable option can take one of a several values:
519-
* false - selectable rows are disabled
520-
* true - selectable rows are enabled, and you can select as many as you want
521-
* 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).
522-
* "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.
523-
* @deprecated Use selectableRows instead
524-
*/
525-
selectable?: boolean | number | "highlight" | undefined;
526-
527517
/**
528518
* The selectableRows option can take one of a several values:
529519
*
@@ -579,14 +569,6 @@ export interface OptionsRows {
579569
*/
580570
selectableRangeClearCellsValue?: unknown;
581571

582-
/**
583-
* 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.
584-
*
585-
* 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 selectableRangeMode to click
586-
* @deprecated Use selectableRowsRangeMode instead
587-
*/
588-
selectableRangeMode?: "click" | undefined;
589-
590572
/**
591573
* By default you can select a range of rows by holding down the shift key and click dragging over a number of rows
592574
* to toggle the selected state state of all rows the cursor passes over.
@@ -601,11 +583,6 @@ export interface OptionsRows {
601583
*/
602584
selectableRowsRangeMode?: "click";
603585

604-
/** By default, row selection works on a rolling basis, if you set the selectable 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 selectableRollingSelection option to false.
605-
* @deprecated Use selectableRowsRollingSelection instead
606-
*/
607-
selectableRollingSelection?: boolean | undefined;
608-
609586
/**
610587
* By default, row selection works on a rolling basis, if you set the selectableRows option to a numeric value then
611588
* when you select past this number of rows, the first row to be selected will be deselected. If you want to
@@ -620,11 +597,6 @@ export interface OptionsRows {
620597
*/
621598
selectableRowsRollingSelection?: boolean;
622599

623-
/** 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 selectablePersistence option to false.
624-
* @deprecated Use selectableRowsPersistence instead
625-
*/
626-
selectablePersistence?: boolean | undefined;
627-
628600
/**
629601
* By default Tabulator will maintain selected rows when the table is filtered, sorted or paginated (but NOT when
630602
* the setData function is used). If you want the selected rows to be cleared whenever the table view is updated
@@ -638,8 +610,8 @@ export interface OptionsRows {
638610
*/
639611
selectableRowsPersistence?: boolean;
640612

641-
/** You many want to exclude certain rows from being selected. The selectableCheck 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. */
642-
selectableCheck?: ((row: RowComponent) => boolean) | undefined;
613+
/** 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. */
614+
selectableRowsCheck?: ((row: RowComponent) => boolean) | undefined;
643615

644616
/** To allow the user to move rows up and down the table, set the movableRows parameter in the options: */
645617
movableRows?: boolean | undefined;

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1757,3 +1757,27 @@ table = new Tabulator("#example-table", {
17571757

17581758
table.setData(table.getAjaxUrl());
17591759
table.setData();
1760+
1761+
// Testing selectableRowsCheck with data and selection verification
1762+
const testData = [
1763+
{ id: 1, name: "John", age: 15, active: true },
1764+
{ id: 2, name: "Jane", age: 25, active: true },
1765+
{ id: 3, name: "Bob", age: 35, active: false },
1766+
];
1767+
1768+
table = new Tabulator("#test-selectableRowsCheck", {
1769+
data: testData,
1770+
selectableRows: true,
1771+
selectableRowsCheck: (row: RowComponent): boolean => {
1772+
return row.getData().age >= 18;
1773+
},
1774+
columns: [
1775+
{ title: "ID", field: "id" },
1776+
{ title: "Name", field: "name" },
1777+
{ title: "Age", field: "age" },
1778+
],
1779+
});
1780+
1781+
table.selectRow([1, 2, 3]);
1782+
const selectedRows = table.getSelectedRows();
1783+
console.log("Number of selected rows:", selectedRows.length); // Should be 2 (only rows with age >= 18)

0 commit comments

Comments
 (0)