I have been attempting to change the background color of a fixed header inside a DataGrid
object in Blazorise for quite some time today, but to no avail, have not succeed in getting the background color changed.
Here is what I am getting
The weird thing is when you remove the defined FixedHeader
option in the code shown below, the styling appears to work.
<DataGrid TItem="PersonData"
Data="@items"
PageSize="300"
Responsive
HeaderRowStyling="@HeaderStyling()"
RowStyling='(x,y ) => y.Style = "background-color: #374151; color: #ffffff;"'
Bordered="true"
RowSelectable="args => false"
FixedHeader
>
<DataGridColumns>
<DataGridColumn .../>
<DataGridColumn .../>
<DataGridColumn .../>
<DataGridColumn .../>
<DataGridColumn .../>
<DataGridColumn .../>
<DisplayTemplate>
<Button Color="Color.Success"> View </Button>
</DisplayTemplate>
</DataGridColumn>
</DataGridColumns>
</DataGrid>
The styling I have for the HeaderRowStyling
variable only works half the time when the FixedHeader
option is present. What will happen is the font color will change to white which is correct, but the desired background color does not change when the FixedHeader
option is present.
The styling is very simple and is implemented below
<style>
.custom_header_styling {
background-color: #1F2937;
color: #ffffff;
}
</style>
@code {
private DataGridRowStyling HeaderStyling()
{
return new DataGridRowStyling
{
Class = "custom_header_styling"
};
}
}
I have looked into the Developer Tools on my browser for the styling because it is clearly being defined but something must be overriding it. It looks like the custom styling is being overwritten by the FixedHeader
background styling.
Is there a way to overcome this limitation or will I have to settle with not using the FixedHeader option if I want custom table styling?