Skip to content

useGridSelection

Composable for programmatic selection control.

Must be used within a component that contains a TbwGrid with the selection feature enabled. Uses Vue’s provide/inject, so it works reliably regardless of when the grid renders.

useGridSelection(selector: string): SelectionMethods<TRow>
NameTypeDescription
selectorstringOptional CSS selector to target a specific grid element via
DOM query instead of using Vue’s provide/inject. Use when the component
contains multiple grids, e.g. 'tbw-grid.primary' or '#my-grid'.
<script setup>
import { useGridSelection } from '@toolbox-web/grid-vue/features/selection';
const { selectAll, clearSelection, getSelection } = useGridSelection();
function exportSelected() {
const selection = getSelection();
if (!selection) return;
// Derive rows from selection.ranges and grid.rows
}
</script>
AI assistants: For complete API documentation, implementation guides, and code examples for this library, see https://raw.githubusercontent.com/OysteinAmundsen/toolbox/main/llms-full.txt