Skip to content

Commit 36bf3c5

Browse files
993664: Updated the UG content and samples for Blazor Pager Component
1 parent 7e8ce2d commit 36bf3c5

File tree

2 files changed

+125
-114
lines changed

2 files changed

+125
-114
lines changed

blazor/pager/getting-started-webapp.md

Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ documentation: ug
99

1010
# Getting started with Blazor Pager Component in Blazor Web App
1111

12-
The Syncfusion<sup style="font-size:70%">&reg;</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<sup style="font-size:70%">&reg;</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**.
1313

1414
{% tabcontents %}
1515

@@ -21,12 +21,15 @@ The Syncfusion<sup style="font-size:70%">&reg;</sup> Blazor Pager component enab
2121

2222
## Create a Blazor Web App in Visual Studio 2022
2323

24+
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<sup style="font-size:70%">&reg;</sup> Blazor Extension](https://blazor.syncfusion.com/documentation/visual-studio-integration/template-studio).
25+
2426
1. Open **Visual Studio 2022** (version 17.8 or later).
2527
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.
3033

3134
## Install Syncfusion<sup style="font-size:70%">&reg;</sup> Blazor NuGet Packages
3235

@@ -68,7 +71,7 @@ N> Syncfusion<sup style="font-size:70%">&reg;</sup> Blazor components are availa
6871

6972
1. Install the latest **.NET SDK** that supports **.NET 8 or later**.
7073
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):
7275

7376
{% tabs %}
7477
{% highlight c# tabtitle="Blazor Web App" %}
@@ -116,9 +119,7 @@ N> Syncfusion<sup style="font-size:70%">&reg;</sup> Blazor components are availa
116119

117120
After installing the NuGet packages, configure the required namespaces and register the Syncfusion<sup style="font-size:70%">&reg;</sup> Blazor service.
118121

119-
1. **Import Namespaces**
120-
121-
- In the **~/ _Imports.razor** file, include:
122+
Import the required namespaces in the **_Imports.razor** file:
122123

123124
{% tabs %}
124125
{% highlight C# tabtitle="~/_Imports.razor" %}
@@ -132,11 +133,9 @@ After installing the NuGet packages, configure the required namespaces and regis
132133
- For **WebAssembly** or **Auto** interactive render modes, update this file in the **Client** project.
133134
- For **Server** interactive render mode, update this file in the **Components** folder.
134135

135-
2. **Register Services in Program.cs**
136+
Next, register the Syncfusion<sup style="font-size:70%">&reg;</sup> Blazor service in the **Program.cs** file:
136137

137-
Add the Syncfusion<sup style="font-size:70%">&reg;</sup> Blazor service in **Program.cs**:
138-
139-
* **Server Render Mode**
138+
**Server Render Mode**
140139

141140
For Server mode, register the service in the **Program.cs** file:
142141

@@ -160,7 +159,7 @@ var app = builder.Build();
160159
{% endtabs %}
161160

162161

163-
* **Auto or WebAssembly Render Mode**
162+
**Auto or WebAssembly Render Mode**
164163

165164
Register the service in both **Server** and **Client** projects:
166165

@@ -227,11 +226,11 @@ N>
227226

228227
## Add Blazor Pager component
229228

230-
The Syncfusion<sup style="font-size:70%">&reg;</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<sup style="font-size:70%">&reg;</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.
231230

232231
**1. Define Render Mode**
233232

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.
235234

236235
{% tabs %}
237236
{% highlight razor %}
@@ -249,26 +248,14 @@ To enable the Pager component in a **Blazor Web App**, define the **render mode*
249248
| **InteractiveWebAssembly**| `@rendermode InteractiveWebAssembly` | Executes component logic on the client using WebAssembly. |
250249
| **InteractiveServer** | `@rendermode InteractiveServer` | Executes component logic on the server using SignalR. |
251250

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.
257-
258-
{% tabs %}
259-
{% highlight razor %}
260-
261-
@rendermode InteractiveAuto
262-
@using Syncfusion.Blazor.Navigations
263-
264-
<SfPager PageSize="5" NumericItemsCount="4" TotalItemsCount="25"></SfPager>
251+
**Interactivity Location**
265252

266-
{% endhighlight %}
267-
{% endtabs %}
253+
* **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**).
268255

269-
**3. Add ListView Component**
256+
**2. Add ListView Component**
270257

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:
272259

273260
```cshtml
274261
@using Syncfusion.Blazor.Navigations
@@ -318,9 +305,32 @@ Create a [ListView](https://blazor.syncfusion.com/documentation/listview/getting
318305
}
319306
```
320307

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.
315+
316+
{% tabs %}
317+
{% highlight razor %}
318+
319+
@rendermode InteractiveAuto
320+
@using Syncfusion.Blazor.Navigations
321+
322+
<SfPager PageSize="5" NumericItemsCount="4" TotalItemsCount="25"></SfPager>
323+
324+
{% endhighlight %}
325+
{% endtabs %}
326+
327+
> For additional properties of SfPager, refer to the API Reference.
328+
321329
**4. Integrate ListView with Pager**
322330

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.
324334

325335
```cshtml
326336
@using Syncfusion.Blazor.Data
@@ -389,7 +399,7 @@ Place the **Pager** below the **ListView** and handle the [ItemClick](https://he
389399

390400
**5. Run the Application**
391401

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.
393403

394404
{% 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)" %}
395405

0 commit comments

Comments
 (0)