Toolbar in Syncfusion Blazor DataGrid
2 May 20256 minutes to read
You can customize the appearance of the toolbar in the Syncfusion Blazor DataGrid using CSS. Here are examples of how to customize the toolbar root element and toolbar button element.
Customizing the toolbar root element
To customize the appearance of toolbar root element, you can use the following CSS code:
.e-grid .e-toolbar-items {
background-color: #deecf9;
}
In this example, the .e-toolbar-items class targets the background color of the toolbar root element. You can modify the background-color
property to change the background color of the toolbar.
Customizing the toolbar button element
To customize the appearance of toolbar buttons, you can use the following CSS code:
.e-grid .e-toolbar .e-btn {
background-color: #deecf9;
}
In this example, the .e-toolbar .e-btn selector targets the background color of the toolbar button elements. You can modify the background-color
property to change the background color of the toolbar buttons.
@using Syncfusion.Blazor.Grids
<SfGrid @ref="Grid" DataSource="@Orders" Height="315" Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update" })" AllowPaging="true">
<GridPageSettings PageSize="8"></GridPageSettings>
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true"></GridEditSettings>
<GridColumns>
<GridColumn Field=@nameof(OrderData.OrderID) HeaderText="Order ID" TextAlign="Syncfusion.Blazor.Grids.TextAlign.Right" Width="140"></GridColumn>
<GridColumn Field=@nameof(OrderData.CustomerID) HeaderText="Customer ID" Width="120"></GridColumn>
<GridColumn Field=@nameof(OrderData.ShipCity) HeaderText="Ship City" Width="100"></GridColumn>
<GridColumn Field=@nameof(OrderData.ShipName) HeaderText="Ship Name" Width="100"></GridColumn>
</GridColumns>
</SfGrid>
<style>
.e-grid .e-toolbar-items {
background-color: #deecf9;
}
.e-grid .e-toolbar .e-btn {
background-color: #c8ddf1;
}
</style>
@code {
private SfGrid<OrderData> Grid;
public List<OrderData> Orders { get; set; }
protected override void OnInitialized()
{
Orders = OrderData.GetAllRecords();
}
}
public class OrderData
{
public static List<OrderData> Orders = new List<OrderData>();
public OrderData(int orderID, string customerID, string shipCity, string shipName)
{
this.OrderID = orderID;
this.CustomerID = customerID;
this.ShipCity = shipCity;
this.ShipName = shipName;
}
public static List<OrderData> GetAllRecords()
{
if (Orders.Count == 0)
{
Orders.Add(new OrderData(10248, "VINET", "Reims", "Vins et alcools Chevalier"));
Orders.Add(new OrderData(10249, "TOMSP", "Münster", "Toms Spezialitäten"));
Orders.Add(new OrderData(10250, "HANAR", "Rio de Janeiro", "Hanari Carnes"));
Orders.Add(new OrderData(10251, "VICTE", "Lyon", "Victuailles en stock"));
Orders.Add(new OrderData(10252, "SUPRD", "Charleroi", "Suprêmes délices"));
Orders.Add(new OrderData(10253, "HANAR", "Rio de Janeiro", "Hanari Carnes"));
Orders.Add(new OrderData(10254, "CHOPS", "Bern", "Chop-suey Chinese"));
Orders.Add(new OrderData(10255, "RICSU", "Genève", "Richter Supermarkt"));
Orders.Add(new OrderData(10256, "WELLI", "Resende", "Wellington Import Export"));
Orders.Add(new OrderData(10257, "HILAA", "San Cristóbal", "Hila Alimentos"));
Orders.Add(new OrderData(10258, "ERNSH", "Graz", "Ernst Handel"));
Orders.Add(new OrderData(10259, "CENTC", "México D.F.", "Centro comercial"));
Orders.Add(new OrderData(10260, "OTTIK", "Köln", "Ottilies Käseladen"));
Orders.Add(new OrderData(10261, "QUEDE", "Rio de Janeiro", "Que delícia"));
Orders.Add(new OrderData(10262, "RATTC", "Albuquerque", "Rattlesnake Canyon Grocery"));
}
return Orders;
}
public int OrderID { get; set; }
public string CustomerID { get; set; }
public string ShipCity { get; set; }
public string ShipName { get; set; }
}