Skip to content

Commit d2c1294

Browse files
Merge pull request #7101 from syncfusion-content/983330-Style2UB
983330: Updated the UG Content and Samples for Style and appearance folder in DataGrid
2 parents 6dd3bea + a6ab41a commit d2c1294

File tree

6 files changed

+381
-347
lines changed

6 files changed

+381
-347
lines changed

blazor-toc.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2181,6 +2181,7 @@
21812181
<li><a href="/blazor/datagrid/style-and-appearance/paging">Paging</a></li>
21822182
<li><a href="/blazor/datagrid/style-and-appearance/selection">Selection</a></li>
21832183
<li><a href="/blazor/datagrid/style-and-appearance/sorting">Sorting</a></li>
2184+
<li><a href="/blazor/datagrid/style-and-appearance/toolbar">Toolbar</a></li>
21842185
</ul>
21852186
</li>
21862187
<li>How To
Lines changed: 60 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,40 @@
11
---
22
layout: post
3-
title: Paging customization in Blazor DataGrid | Syncfusion
4-
description: Learn here all about paging in Syncfusion Blazor DataGrid and more.
3+
title: Pager styling and customization in Blazor DataGrid | Syncfusion
4+
description: Learn how to style the Syncfusion Blazor DataGrid pager using CSS—customize container, buttons, numeric items, and page indicator.
55
platform: Blazor
66
control: DataGrid
77
documentation: ug
88
---
99

10-
# Paging in Syncfusion<sup style="font-size:70%">&reg;</sup> Blazor DataGrid
10+
# Paging customization in Syncfusion Blazor DataGrid
1111

12-
You can customize the appearance of the paging elements in the Syncfusion<sup style="font-size:70%">&reg;</sup> Blazor DataGrid using CSS. Here are examples of how to customize the pager root element, pager container element, pager navigation elements, pager page numeric link elements, and pager current page numeric element.
12+
The appearance of paging elements in the Syncfusion<sup style="font-size:70%">&reg;</sup> Blazor DataGrid can be customized using CSS. Styling options are available for different parts of the pager interface:
1313

14-
## Customizing the Blazor DataGrid pager root element
14+
- **Root container:** The outermost wrapper that holds all pager content.
15+
- **Pager container:** The inner layout that positions the controls.
16+
- **Navigation buttons:** Commands for first, previous, next, and last page navigation.
17+
- **Numeric page indicators:** Indicators that jump directly to specific pages.
18+
- **Current page indicator:** The highlight that marks the active numeric page button.
1519

16-
To customize the appearance of the Grid pager root element, you can use the following CSS code:
20+
## Customize the pager root element
21+
22+
The **.e-gridpager** class styles the pager root element in the Blazor DataGrid. Use CSS to adjust its appearance:
1723

1824
```css
1925
.e-grid .e-gridpager {
2026
font-family: cursive;
2127
background-color: #deecf9;
2228
}
2329
```
24-
In this example, the **.e-gridpager** class targets the pager root element. You can modify the `font-family` to change the font family and `background-color` property to change the background color of the pager.
2530

26-
![Grid pager root element](../images/style-and-appearance/grid-pager-root-element.png)
31+
Properties like **font-family**, **background-color**, and spacing-related styles can be changed to fit the grid layout design.
32+
33+
![Pager root element](../images/style-and-appearance/grid-pager-root-element.png)
2734

28-
## Customizing the Blazor DataGrid pager container element
35+
## Customize the pager container element
2936

30-
To customize the appearance of the Grid pager container element, you can use the following CSS code:
37+
The **.e-pagercontainer** class styles the pager container in the Syncfusion<sup style="font-size:70%">&reg;</sup> Blazor DataGrid. Apply CSS to modify its look:
3138

3239
```css
3340
.e-grid .e-pagercontainer {
@@ -36,13 +43,13 @@ To customize the appearance of the Grid pager container element, you can use the
3643
}
3744
```
3845

39-
In this example, the **.e-pagercontainer** class targets the pager container element. You can modify the `border` property and `font-family` property to change the border color and font family of the pager container.
46+
Properties such as **font-family**, **background-color**, and spacing-related styles can be adjusted to align with the grid design.
4047

41-
![Grid pager container element](../images/style-and-appearance/grid-pager-container-element.png)
48+
![Pager container element](../images/style-and-appearance/grid-pager-container-element.png)
4249

43-
## Customizing the Blazor DataGrid pager navigation elements
50+
## Customize the pager navigation elements
4451

45-
To customize the appearance of the Grid pager navigation elements, you can use the following CSS code:
52+
The **.e-prevpagedisabled**, **.e-prevpage**, **.e-nextpage**, **.e-nextpagedisabled**, **.e-lastpagedisabled**, **.e-lastpage**, **.e-firstpage**, and **.e-firstpagedisabled** classes define the appearance of the pager navigation buttons in the Blazor DataGrid. Apply CSS to customize their styling:
4653

4754
```css
4855
.e-grid .e-gridpager .e-prevpagedisabled,
@@ -57,34 +64,34 @@ To customize the appearance of the Grid pager navigation elements, you can use t
5764
}
5865
```
5966

60-
In this example, the classes **.e-prevpagedisabled, .e-prevpage, .e-nextpage, .e-nextpagedisabled, .e-lastpagedisabled, .e-lastpage, .e-firstpage,** and **.e-firstpagedisabled** target the various pager navigation elements. You can modify the `background-color` property to change the background color of these elements.
67+
Adjust properties like **background-color** to match the design, while keeping clear focus styles for accessibility.
6168

62-
![Grid pager navigation elements](../images/style-and-appearance/grid-pager-navigation-element.png)
69+
![Pager navigation elements](../images/style-and-appearance/grid-pager-navigation-element.png)
6370

64-
## Customizing the Blazor DataGrid pager page numeric link elements
71+
## Customize the pager numeric button elements
6572

66-
To customize the appearance of the Grid pager current page numeric link elements, you can use the following CSS code:
73+
The **.e-numericitem** class styles the numeric page buttons in the Blazor DataGrid. Apply CSS to change their appearance:
6774

6875
```css
6976
.e-grid .e-gridpager .e-numericitem {
7077
background-color: #5290cb;
7178
color: #ffffff;
7279
cursor: pointer;
73-
}
74-
80+
}
81+
7582
.e-grid .e-gridpager .e-numericitem:hover {
7683
background-color: white;
77-
color: #007bff;
84+
color: #007bff;
7885
}
7986
```
8087

81-
In this example, the **.e-numericitem** class targets the page numeric link elements. You can modify the `background-color`, `color` properties to change the background color and text color of these elements.
88+
Modify properties such as **background-color**, **color**, and **hover** effects to improve clarity and interaction.
8289

83-
![Grid pager page numeric link elements](../images/style-and-appearance/pager-page-numeric-link-elements.png)
90+
![Pager numeric button elements](../images/style-and-appearance/pager-page-numeric-link-elements.png)
8491

85-
## Customizing the Blazor DataGrid pager current page numeric element
92+
## Customize the current page numeric element
8693

87-
To customize the appearance of the Grid pager current page numeric element, you can use the following CSS code:
94+
The **.e-currentitem** class styles the current page indicator in the Blazor DataGrid pager. Use CSS to adjust it:
8895

8996
```css
9097
.e-grid .e-gridpager .e-currentitem {
@@ -93,9 +100,9 @@ To customize the appearance of the Grid pager current page numeric element, you
93100
}
94101
```
95102

96-
In this example, the **.e-currentitem** class targets the current page numeric item. You can modify the `background-color` property to change the background color of this element and `color` property to change the text color.
103+
Change properties like **background-color** and **color** to highlight the active page.
97104

98-
![Grid pager current page numeric element](../images/style-and-appearance/grid-pager-current-page-numeric-element.png)
105+
![Current page numeric element](../images/style-and-appearance/grid-pager-current-page-numeric-element.png)
99106

100107

101108
{% tabs %}
@@ -106,10 +113,10 @@ In this example, the **.e-currentitem** class targets the current page numeric i
106113
<SfGrid @ref="Grid" DataSource="@Orders" Height="315" AllowPaging="true">
107114
<GridPageSettings PageSize="8"></GridPageSettings>
108115
<GridColumns>
109-
<GridColumn Field=@nameof(OrderData.OrderID) HeaderText="Order ID" TextAlign="Syncfusion.Blazor.Grids.TextAlign.Right" Width="140"></GridColumn>
116+
<GridColumn Field=@nameof(OrderData.OrderID) HeaderText="Order ID" TextAlign="TextAlign.Right" Width="140"></GridColumn>
110117
<GridColumn Field=@nameof(OrderData.CustomerID) HeaderText="Customer ID" Width="120"></GridColumn>
111-
<GridColumn Field=@nameof(OrderData.Freight) HeaderText="Freight" TextAlign="Syncfusion.Blazor.Grids.TextAlign.Right" Width="120"></GridColumn>
112-
<GridColumn Field=@nameof(OrderData.OrderDate) HeaderText="Order Date" Format="d" Width="100" TextAlign="Syncfusion.Blazor.Grids.TextAlign.Right"></GridColumn>
118+
<GridColumn Field=@nameof(OrderData.Freight) HeaderText="Freight" TextAlign="TextAlign.Right" Width="120"></GridColumn>
119+
<GridColumn Field=@nameof(OrderData.OrderDate) HeaderText="Order Date" Format="d" Width="100" TextAlign="TextAlign.Right"></GridColumn>
113120
</GridColumns>
114121
</SfGrid>
115122

@@ -122,11 +129,10 @@ In this example, the **.e-currentitem** class targets the current page numeric i
122129
background-color: #5290cb;
123130
color: #ffffff;
124131
cursor: pointer;
125-
}
126-
132+
}
127133
.e-grid .e-gridpager .e-numericitem:hover {
128134
background-color: white;
129-
color: #007bff;
135+
color: #007bff;
130136
}
131137
.e-grid .e-gridpager .e-prevpagedisabled,
132138
.e-grid .e-gridpager .e-prevpage,
@@ -150,7 +156,7 @@ In this example, the **.e-currentitem** class targets the current page numeric i
150156

151157
@code {
152158
private SfGrid<OrderData> Grid;
153-
public List<OrderData> Orders { get; set; }
159+
private List<OrderData> Orders { get; set; }
154160

155161
protected override void OnInitialized()
156162
{
@@ -162,35 +168,35 @@ In this example, the **.e-currentitem** class targets the current page numeric i
162168

163169
{% highlight c# tabtitle="OrderData.cs" %}
164170

165-
public class OrderData
171+
internal sealed class OrderData
166172
{
167-
public static List<OrderData> Orders = new List<OrderData>();
173+
private static readonly List<OrderData> Data = new();
168174

169175
public OrderData(int orderID, string customerID, double freight, DateTime orderDate)
170176
{
171-
this.OrderID = orderID;
172-
this.CustomerID = customerID;
173-
this.Freight = freight;
174-
this.OrderDate = orderDate;
177+
OrderID = orderID;
178+
CustomerID = customerID;
179+
Freight = freight;
180+
OrderDate = orderDate;
175181
}
176182

177-
public static List<OrderData> GetAllRecords()
183+
internal static List<OrderData> GetAllRecords()
178184
{
179-
if (Orders.Count == 0)
185+
if (Data.Count == 0)
180186
{
181-
Orders.Add(new OrderData(10248, "VINET", 32.38, new DateTime(2024, 1, 10)));
182-
Orders.Add(new OrderData(10249, "TOMSP", 11.61, new DateTime(2024, 1, 11)));
183-
Orders.Add(new OrderData(10250, "HANAR", 65.83, new DateTime(2024, 1, 12)));
184-
Orders.Add(new OrderData(10251, "VICTE", 41.34, new DateTime(2024, 1, 13)));
185-
Orders.Add(new OrderData(10252, "SUPRD", 51.3, new DateTime(2024, 1, 14)));
186-
Orders.Add(new OrderData(10253, "HANAR", 58.17, new DateTime(2024, 1, 15)));
187-
Orders.Add(new OrderData(10254, "CHOPS", 22.98, new DateTime(2024, 1, 16)));
188-
Orders.Add(new OrderData(10255, "RICSU", 148.33, new DateTime(2024, 1, 17)));
189-
Orders.Add(new OrderData(10256, "WELLI", 13.97, new DateTime(2024, 1, 18)));
190-
Orders.Add(new OrderData(10257, "HILAA", 81.91, new DateTime(2024, 1, 19)));
187+
Data.Add(new OrderData(10248, "VINET", 32.38, new DateTime(2024, 1, 10)));
188+
Data.Add(new OrderData(10249, "TOMSP", 11.61, new DateTime(2024, 1, 11)));
189+
Data.Add(new OrderData(10250, "HANAR", 65.83, new DateTime(2024, 1, 12)));
190+
Data.Add(new OrderData(10251, "VICTE", 41.34, new DateTime(2024, 1, 13)));
191+
Data.Add(new OrderData(10252, "SUPRD", 51.3, new DateTime(2024, 1, 14)));
192+
Data.Add(new OrderData(10253, "HANAR", 58.17, new DateTime(2024, 1, 15)));
193+
Data.Add(new OrderData(10254, "CHOPS", 22.98, new DateTime(2024, 1, 16)));
194+
Data.Add(new OrderData(10255, "RICSU", 148.33, new DateTime(2024, 1, 17)));
195+
Data.Add(new OrderData(10256, "WELLI", 13.97, new DateTime(2024, 1, 18)));
196+
Data.Add(new OrderData(10257, "HILAA", 81.91, new DateTime(2024, 1, 19)));
191197
}
192198

193-
return Orders;
199+
return Data;
194200
}
195201

196202
public int OrderID { get; set; }
@@ -202,4 +208,4 @@ public class OrderData
202208
{% endhighlight %}
203209
{% endtabs %}
204210

205-
{% previewsample "https://blazorplayground.syncfusion.com/embed/BDVejyDhUQlhxJtR?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5" %}
211+
{% previewsample "https://blazorplayground.syncfusion.com/embed/LtBeitMeWnMUTNeW?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5" %}

0 commit comments

Comments
 (0)