Is there a way to customize back ground color for rows based on data in a cell? I need the color of the row to be aqua for rule: "Round Robin" and green if rule:"DNS Delegation" Example:
<script>
import { DataTable, Pagination } 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 pageSize = 5;
let page = 1;
</script>
<DataTable
sortable
title="Load balancers"
description="Your organization's active load balancers."
headers={[
{ key: "name", value: "Name" },
{ key: "protocol", value: "Protocol" },
{ key: "port", value: "Port" },
{ key: "rule", value: "Rule" },
]}
{pageSize}
{page}
{rows}
/>
<Pagination
bind:pageSize
bind:page
totalItems={rows.length}
pageSizeInputDisabled
/>
<style>
:global(.round-robin) {
background-color: aqua;
}
:global(.dns-delegation) {
background-color: green;
}
</style>
I was hoping to apply a class to the Row item:
<DataTableRow class={row.item.rule}>
:global(.round-robin) {
background-color: aqua;
}
:global(.dns-delegation) {
background-color: green;
}