<SfGrid DataSource="@Orders" Toolbar="@(new List<string>() { "Search", "Add", "Edit", "Delete" })"
AllowSelection="true"RowHeight="60" AllowSorting="true" AllowFiltering="true" AllowPaging="true" Height="315">
<GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Menu"></GridFilterSettings>
<GridColumns>
<GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" TextAlign="TextAlign.Right" Width="120"></GridColumn>
<GridColumn Field=@nameof(Order.OrderDate) HeaderText=" Order Date" Format="d" Type="ColumnType.Date" TextAlign="TextAlign.Right" Width="130"></GridColumn>
<GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn>
<GridColumn Field=@nameof(Order.Comments) HeaderText="Customer Name" ClipMode="ClipMode.EllipsisWithTooltip" Width="150"></GridColumn>
</GridColumns>
</SfGrid> |
|
<SfGrid DataSource="@Orders" AllowTextWrap="true" Toolbar="@(new List<string>() { "Search", "Add", "Edit", "Delete" })" AllowSelection="true"RowHeight="60" AllowSorting="true" AllowFiltering="true" AllowPaging="true" Height="315">
<GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Menu"></GridFilterSettings>
<GridColumns>
<GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" TextAlign="TextAlign.Right" Width="120"></GridColumn>
<GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="150"></GridColumn>
<GridColumn Field=@nameof(Order.OrderDate) HeaderText=" Order Date" Format="d" Type="ColumnType.Date" TextAlign="TextAlign.Right" Width="130"></GridColumn>
<GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn>
<GridColumn Field=@nameof(Order.Comments) HeaderText="Customer Name" CustomAttributes="@(new Dictionary<string, object>(){ { "class", "e-attr" }})" Width="150"></GridColumn>
</GridColumns>
</SfGrid>
<style>
td.e-rowcell.e-attr {
display: -webkit-box;
max-height: 60px;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
overflow: hidden;
}
</style>
|
|
How can we apply a class like this for the header row?
Using the header cell wrap feature, I want to only wrap a max of 3 lines. If you resize the window and you don't have autofit on a row, your header row can get huuuuge.
Normal Width:
When window width is slightly reduced:
Hi Andy,
Based on your requirements, we suggest using the following CSS customization to
achieve your goals. Please refer to the code snippet and sample below for your
reference.
<style> .e-grid .e-headercelldiv { display: -webkit-box; max-height: 60px; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
</style> |
Sample: https://blazorplayground.syncfusion.com/embed/hXLftHDAUTnWPVca?appbar=true&editor=true&result=true&errorlist=true&theme=bootstrap5
Regards,
Prathap Senthil