The selectAllRows() method has been added to the TablixJS Table class to provide a convenient way to select all currently visible/filtered rows.
table.selectAllRows(): number
None
numberdataIdKey option specified during table initializationselection.enabled: true)single and multi selection modesselectAll eventThe method triggers a custom selectAll event with the following payload:
{
selectedIds: string[], // Array of selected row IDs
selectedData: object[], // Array of selected row data objects
count: number // Number of rows selected
}
// Select all visible rows
const selectedCount = table.selectAllRows();
console.log(`Selected ${selectedCount} rows`);
// Listen for selectAll events
table.eventManager.on('selectAll', (event) => {
console.log(`Selected ${event.count} rows:`, event.selectedData);
});
// Trigger selection
table.selectAllRows();
document.addEventListener('keydown', (e) => {
if (e.key === 'a' && (e.ctrlKey || e.metaKey)) {
e.preventDefault();
table.selectAllRows();
}
});
// Apply a filter first
await table.applyFilter('department', {
type: 'value',
values: ['Engineering']
});
// Select all filtered rows (only Engineering employees)
const count = table.selectAllRows();
console.log(`Selected ${count} Engineering employees`);
The method includes built-in warnings for common issues:
selection.enabled is falsetable.getSelectedData() - Get selected row objectstable.getSelectedIds() - Get selected row IDs table.getSelectionCount() - Get count of selected rowstable.clearSelection() - Clear all selectionstable.selectRows(ids) - Select specific rows by IDtable.deselectRows(ids) - Deselect specific rows by IDIf you were previously using a custom selectAllRows() implementation like:
// Old custom implementation
function selectAllRows() {
const allData = table.getData();
const allIds = allData.map(row => row.id.toString());
table.selectRows(allIds);
}
You can now replace it with the built-in method:
// New built-in API
const count = table.selectAllRows();
The built-in method provides better error handling, event triggering, and return value for improved developer experience.