You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: blazor/pager/getting-started-webapp.md
+45-35Lines changed: 45 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ documentation: ug
9
9
10
10
# Getting started with Blazor Pager Component in Blazor Web App
11
11
12
-
The Syncfusion<supstyle="font-size:70%">®</sup> Blazor Pager component enables navigation through large collections by dividing content into multiple pages. This guide details the integration of the [SfPager](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.SfPager.html) component in a **Blazor Web App** using [Visual Studio](https://visualstudio.microsoft.com/vs/) or **Visual Studio Code**. The instructions follow .**NET 8 or later** standards and include configuration for **interactive render modes**, **interactivity settings**, and **service registration** for **Server** and **WebAssembly** hosting models.
12
+
The Syncfusion<supstyle="font-size:70%">®</sup> Blazor Pager component enables navigation through large collections by dividing content into multiple pages. This guide details the integration of the [SfPager](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.SfPager.html) component in a **Blazor Web App** using [Visual Studio](https://visualstudio.microsoft.com/vs/) or **Visual Studio Code**.
A **Blazor Web App** can be created using **Visual Studio** with the built-in [Microsoft templates](https://learn.microsoft.com/en-us/aspnet/core/blazor/tooling?view=aspnetcore-10.0&pivots=vs) or the [Syncfusion<supstyle="font-size:70%">®</sup> Blazor Extension](https://blazor.syncfusion.com/documentation/visual-studio-integration/template-studio).
25
+
24
26
1. Open **Visual Studio 2022** (version 17.8 or later).
25
27
2. Select **Create a new project**.
26
-
3. From [Microsoft Templates](https://learn.microsoft.com/en-us/aspnet/core/blazor/tooling?view=aspnetcore-8.0), choose **Blazor Web App** and click **Next**.
27
-
4. Specify the **project name**, **location**, and **solution name**, then click **Next**.
28
-
5. In **Additional information**, select the required [Interactive render mode](https://learn.microsoft.com/en-us/aspnet/core/blazor/components/render-modes?view=aspnetcore-9.0#render-modes) and [Interactivity location](https://learn.microsoft.com/en-us/aspnet/core/blazor/tooling?view=aspnetcore-9.0&pivots=vs).
29
-
6. Review the remaining options and click **Create**.
28
+
3. Choose **Blazor Web App** from the list of templates and click **Next**.
29
+
4. Specify the **project name**, **location**, and **solution settings**, then click **Next**.
30
+
5. Select the **target framework** as **.NET 8.0 or later** (choose the latest installed version available on the system).
31
+
6. Choose the [Interactive render mode](https://learn.microsoft.com/en-us/aspnet/core/blazor/components/render-modes?view=aspnetcore-9.0#render-modes)(Server, WebAssembly, or Auto) and [Interactivity location](https://learn.microsoft.com/en-us/aspnet/core/blazor/tooling?view=aspnetcore-9.0&pivots=vs).
32
+
7. Review the remaining options and click **Create** to generate the project.
1. Install the latest **.NET SDK** that supports **.NET 8 or later**.
70
73
2. Open **Visual Studio Code** and launch the integrated terminal (**Ctrl + `**).
71
-
3. Execute the following command to create a **Blazor Web App** with **Auto**[Interactive render mode](https://learn.microsoft.com/en-us/aspnet/core/blazor/components/render-modes?view=aspnetcore-9.0#render-modes):
74
+
3. Execute the following command to create a **Blazor Web App** with **Auto**[Interactive render mode](https://learn.microsoft.com/en-us/aspnet/core/blazor/components/render-modes?view=aspnetcore-10.0#render-modes):
After installing the NuGet packages, configure the required namespaces and register the Syncfusion<supstyle="font-size:70%">®</sup> Blazor service.
118
121
119
-
1.**Import Namespaces**
120
-
121
-
- In the **~/ _Imports.razor** file, include:
122
+
Import the required namespaces in the **_Imports.razor** file:
122
123
123
124
{% tabs %}
124
125
{% highlight C# tabtitle="~/_Imports.razor" %}
@@ -132,11 +133,9 @@ After installing the NuGet packages, configure the required namespaces and regis
132
133
- For **WebAssembly** or **Auto** interactive render modes, update this file in the **Client** project.
133
134
- For **Server** interactive render mode, update this file in the **Components** folder.
134
135
135
-
2.**Register Services in Program.cs**
136
+
Next, register the Syncfusion<supstyle="font-size:70%">®</sup> Blazor service in the **Program.cs** file:
136
137
137
-
Add the Syncfusion<supstyle="font-size:70%">®</sup> Blazor service in **Program.cs**:
138
-
139
-
***Server Render Mode**
138
+
**Server Render Mode**
140
139
141
140
For Server mode, register the service in the **Program.cs** file:
142
141
@@ -160,7 +159,7 @@ var app = builder.Build();
160
159
{% endtabs %}
161
160
162
161
163
-
***Auto or WebAssembly Render Mode**
162
+
**Auto or WebAssembly Render Mode**
164
163
165
164
Register the service in both **Server** and **Client** projects:
166
165
@@ -227,11 +226,11 @@ N>
227
226
228
227
## Add Blazor Pager component
229
228
230
-
The Syncfusion<supstyle="font-size:70%">®</sup> Blazor Pager component provides navigation for large collections by dividing content into multiple pages. It can be integrated with other components such as [ListView](https://blazor.syncfusion.com/documentation/listview/getting-started)to enable page-wise navigation in a **Blazor Web App**.
229
+
The Syncfusion<supstyle="font-size:70%">®</sup> Blazor Pager component can be integrated with other components to enable page navigation for large data collections. This configuration shows how to use the **Pager** with the [ListView](https://blazor.syncfusion.com/documentation/listview/getting-started)component.
231
230
232
231
**1. Define Render Mode**
233
232
234
-
To enable the Pager component in a **Blazor Web App**, define the **render mode**in a**.razor** file.
233
+
To use the **Pager** component in a **Blazor Web App**, set the **render mode**at the top of the**.razor** file.
235
234
236
235
{% tabs %}
237
236
{% highlight razor %}
@@ -249,26 +248,14 @@ To enable the Pager component in a **Blazor Web App**, define the **render mode*
249
248
|**InteractiveWebAssembly**|`@rendermode InteractiveWebAssembly`| Executes component logic on the client using WebAssembly. |
250
249
|**InteractiveServer**|`@rendermode InteractiveServer`| Executes component logic on the server using SignalR. |
251
250
252
-
> When interactivity location is **Global**, render mode is configured in **App.razor** by default.
253
-
254
-
**2. Add Pager Component**
255
-
256
-
To enable the Pager component in a **Blazor Web App**, add the [SfPager](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.SfPager.html) control in a **.razor** file.
***Global**: Render mode is configured in **App.razor** and applies to the entire application by default.
254
+
***Per page/component**: Render mode is set at the top of the specific **Razor** file (for example, **Pages/Index.razor**).
268
255
269
-
**3. Add ListView Component**
256
+
**2. Add ListView Component**
270
257
271
-
Create a[ListView](https://blazor.syncfusion.com/documentation/listview/getting-started) and bind it to a collection of data:
258
+
Add the[ListView](https://blazor.syncfusion.com/documentation/listview/getting-started)component in the **Pages/Index.razor** file and bind it to a collection:
272
259
273
260
```cshtml
274
261
@using Syncfusion.Blazor.Navigations
@@ -318,9 +305,32 @@ Create a [ListView](https://blazor.syncfusion.com/documentation/listview/getting
318
305
}
319
306
```
320
307
308
+
**3. Add Pager component**
309
+
310
+
Add the [SfPager](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.SfPager.html) component in the same file (**Pages/Index.razor**) below the **ListView**. Configure the essential properties:
311
+
312
+
*[PageSize](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.SfPager.html#Syncfusion_Blazor_Navigations_SfPager_PageSize) – defines the number of items displayed per page.
313
+
*[NumericItemsCount](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.SfPager.html#Syncfusion_Blazor_Navigations_SfPager_NumericItemsCount) – specifies the count of numeric pager buttons.
314
+
*[TotalItemsCount](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.SfPager.html#Syncfusion_Blazor_Navigations_SfPager_TotalItemsCount) – indicates the total number of records in the data source.
> For additional properties of SfPager, refer to the API Reference.
328
+
321
329
**4. Integrate ListView with Pager**
322
330
323
-
Place the **Pager** below the **ListView** and handle the [ItemClick](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.SfPager.html#Syncfusion_Blazor_Navigations_SfPager_ItemClick) event to update the displayed data:
331
+
To enable paging functionality, bind the **ListView** data for the current page by applying **Skip** and **Take** operations on the collection. These operations are based on the [PageSize](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.SfPager.html#Syncfusion_Blazor_Navigations_SfPager_PageSize) property of the Pager component.
332
+
333
+
The [ItemClick](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Navigations.SfPager.html#Syncfusion_Blazor_Navigations_SfPager_ItemClick) event is triggered when a pager item is clicked. This event updates the **Skip** and **Take** values dynamically according to the selected page, ensuring that the correct subset of data is displayed in the ListView.
324
334
325
335
```cshtml
326
336
@using Syncfusion.Blazor.Data
@@ -389,7 +399,7 @@ Place the **Pager** below the **ListView** and handle the [ItemClick](https://he
389
399
390
400
**5. Run the Application**
391
401
392
-
Press <kbd>Ctrl</kbd>+<kbd>F5</kbd> (Windows) or <kbd>⌘</kbd>+<kbd>F5</kbd> (macOS) to launch the application. The Pager component will render and enable navigation through the collection.
402
+
Press <kbd>Ctrl</kbd>+<kbd>F5</kbd> (Windows) or <kbd>⌘</kbd>+<kbd>F5</kbd> (macOS) to launch the application. The **Pager** component will render and enable navigation through the collection.
393
403
394
404
{% previewsample "https://blazorplayground.syncfusion.com/embed/VjrpjCqNBJBSbqWn?appbar=false&editor=false&result=true&errorlist=false&theme=bootstrap5" backgroundimage "[Blazor Pager with ListView](./images/blazor-pager-with-list-view.gif)" %}
0 commit comments