diff --git a/docs/src/pages/components/DataTable.svx b/docs/src/pages/components/DataTable.svx index 8c206dca..f5650668 100644 --- a/docs/src/pages/components/DataTable.svx +++ b/docs/src/pages/components/DataTable.svx @@ -460,6 +460,22 @@ title="Load balancers" description="Your organization's active load balancers." +### Filterable + +By default, `ToolbarSearch` will not filter `DataTable` rows. + +Set `shouldFilterRows` to `true` to enable client-side filtering. The default filtering performs a basic string comparison on cell values that are of a string or a number type. + +Note that in-memory filtering is not optimal for large data sets, where you might consider using server-side search. + + + +### Filterable (custom) + +`shouldFilterRows` also accepts a function and passes it the current row and value. It expects the function to return a boolean. + + + ### Zebra stripes + import { + DataTable, + Toolbar, + ToolbarContent, + ToolbarSearch, + ToolbarMenu, + ToolbarMenuItem, + Button, + } from "carbon-components-svelte"; + + let rows = Array.from({ length: 10 }).map((_, i) => ({ + id: i, + name: "Load Balancer " + (i + 1), + protocol: "HTTP", + port: 3000 + i * 10, + rule: i % 2 ? "Round robin" : "DNS delegation", + })); + + + + + + + + Restart all + + API documentation + + Stop all + + + + + diff --git a/docs/src/pages/framed/DataTable/DataTableFilterable.svelte b/docs/src/pages/framed/DataTable/DataTableFilterable.svelte new file mode 100644 index 00000000..3d80b057 --- /dev/null +++ b/docs/src/pages/framed/DataTable/DataTableFilterable.svelte @@ -0,0 +1,46 @@ + + + + + + + + Restart all + + API documentation + + Stop all + + + + +