Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

In Blazor Fluent Grid, how to add alternate background style to odd rows?

$
0
0

I'm trying add alternate background style to odd rows in Blazor Fluent Gridit seams that it is not possible out of the box, so I tried with some CSS like

.fluent-data-grid tbody tr:nth-child(odd) {     background: blue !important; }

and

fluent-data-grid-row:nth-child(odd) {    background: blue !important;}

But it is not working. I can set for the column like this and it works fine

 .fluent-data-grid td:nth-child(odd) {     background: blue !important; }

To replicate create at new Blazor Fluent Web app in VS, and in the Weather.razor page add the style

@page "/weather"@attribute [StreamRendering]<style>    .fluent-data-grid tr:nth-child(odd) {        background: blue !important;    }    .fluent-data-grid td:nth-child(odd) {        background: red !important;    }</style><PageTitle>Weather</PageTitle><h1>Weather</h1><p>This component demonstrates showing data.</p><FluentDataGrid Id="weathergrid" Items="@forecasts" GridTemplateColumns="1fr 1fr 1fr 2fr" Loading="@(forecasts == null)" Style="height:204px;" TGridItem="WeatherForecast"><PropertyColumn Title="Date" Property="@(c => c!.Date)" Align="Align.Start"/><PropertyColumn Title="Temp. (C)" Property="@(c => c!.TemperatureC)" Align="Align.Center"/><PropertyColumn Title="Temp. (F)" Property="@(c => c!.TemperatureF)" Align="Align.Center"/><PropertyColumn Title="Summary" Property="@(c => c!.Summary)" Align="Align.End"/></FluentDataGrid>

Run it and see that it has no effect on the row color

enter image description here

How do I get this to work?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>