getSelectedTableRows
If you have selected multiple rows, you you will at some point want to accomplish an action against all of the rows, like deleting them all or updating them all.
Because each TableRow
has an id
property, you'll want to get an array of all of the selected rows. At any point, you can do this with the getSelectedTableRows
utility functions.
It takes in one property, which is the id of the table from which would want to get the row IDs. If you only have one table on the page, getSelectedTableRows
will work without an ID property because it will target the first table it finds. With multiple tables, you should provide the ID.
Props
id string
The ID of the table that you are targeting
Returns
Array
Returns a list of all IDs of the selected rows.
<script>
import { Table, TableHeader, TableRow, getSelectedTableRows } from "bubbles-ui";
<Table id="table-id">
<TableHeader
cells={[
{
checkbox: true,
options: [
{
label: "Print Selected Rows To Console",
value: "label1",
onselect: (event) => {
const ids = getSelectedTableRows("table-id");
deselectTableRows("table-id");
},
},
],
},
{ label: "Name" },
{ label: "Weight" },
{ label: "Type(s)" },
]}
>
<!-- Your table rows would go here -->
</TableHeader>
</Table>;
</script>