尝试设置 MudBlazor DataGrid 的列宽可能会很痛苦。由于某种原因,通过 Column 的 CellClass 或 HeaderClass 或 CellStyle 或 HeaderStyle 设置样式不起作用。
添加标签解决了问题:
<ColGroup>
<col style="width: 20%;" />
<col style="width: 10%;" />
<col style="width: 20%;" />
<col style="width: 20%;"/>
<col />
</ColGroup>
<Columns>
<PropertyColumn Property="x => x.Number" Title="Nr" />
<PropertyColumn Property="x => x.Sign" />
<PropertyColumn Property="x => x.Name" />
<PropertyColumn Property="x => x.Position" />
<PropertyColumn Property="x => x.Molar" Title="Molar mass" />
</Columns>
</MudDataGrid>```