Implementing Filtering via dropdown #1617
Unanswered
normanmadrid
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Currently, the One workaround is to provide the selected dropdown value to <script>
import {
Dropdown,
DataTable,
Toolbar,
ToolbarContent,
ToolbarSearch,
} 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",
}));
let selectedId = "1";
const items = [
{ id: "1", text: "Load Balancer 1" },
{ id: "2", text: "Load Balancer 2" },
];
$: value = items.find((item) => item.id === selectedId).text;
</script>
<Dropdown bind:selectedId {items} />
<br />
<DataTable
headers={[
{ key: "name", value: "Name" },
{ key: "protocol", value: "Protocol" },
{ key: "port", value: "Port" },
{ key: "rule", value: "Rule" },
]}
{rows}
>
<Toolbar>
<ToolbarContent>
<ToolbarSearch persistent shouldFilterRows bind:value />
</ToolbarContent>
</Toolbar>
</DataTable>
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
disclaimer: I just started developing with svelte a week ago
I'm trying to implement a filter using the carbon dropdown component, I thought I could do this by dispatching an event on select, then going through the rows data with a conditional, when the conditional activates (filter applied) i add the ID of that row to filteredRowIds which is bound to my search bar. the problem I seem to be facing is even tho I add that row's ID to the filteredRowIds its not updating the table, some help would be very much appreciated, thanks!
Beta Was this translation helpful? Give feedback.
All reactions