Skip to content

Commit 74297a3

Browse files
svdimitrmarin-bratanov
authored andcommitted
docs(pager): added examples with respective media files; Examples section; Feature section;
1 parent 49f19c6 commit 74297a3

File tree

3 files changed

+85
-54
lines changed

3 files changed

+85
-54
lines changed
10.2 KB
Loading
46.7 KB
Loading

components/pager/overview.md

Lines changed: 85 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,118 @@
11
---
2-
title: Paging
2+
title: Pager
33
page_title: Pager for Blazor Overview
4-
description: Enable and configure paging in Grid for Blazor
4+
description: Add a page navigation to Blazor application
55
slug: components-pager-overview
66
tags: telerik,blazor,pager,paging
77
published: True
88
position: 20
99
---
1010

11-
# Grid Paging
11+
# Pager Overview
1212

13-
The Grid component offers support for paging.
13+
The `Pager` component will enable you to add page navigation in your Blazor application. It follows the design patter of our components but as standalone one can be used outside of Grid.
1414

15-
To enable paging, set its `Pageable` property to `true`.
15+
To use Telerik Pager component for Blazor:
16+
1. Add the `TelerikPager` tag
17+
1. (optional) Populate it's `Total` parameter
18+
1. (optional) Set it's `ButtonCount` parameter
19+
1. (optional) Set the `PageChanged` parameter
20+
1. (optional) Set `Page` or `@bind-Page` (one and two-way data binding)
21+
1. (optional) Set a `PageSize`
1622

17-
You can control the number of records per page through the `PageSize` property.
18-
19-
You can set the current page of the grid through its integer `Page` property.
20-
21-
>caption Enable paging in Telerik Grid
23+
>caption Basic setup of Pager component in your application
2224
2325
````CSHTML
24-
Enable paging and start on the second page.
26+
@*Basic Pager configuration.*@
27+
28+
<TelerikPager Total="TotalItems"
29+
ButtonCount="ButtonCount"
30+
PageSize="ItemsOnPage"
31+
@bind-Page="CurrentPage">
2532
26-
<TelerikGrid Data="@MyData" Pageable="true" PageSize="15" Page="2" Height="500px">
27-
<GridColumns>
28-
<GridColumn Field="ID"></GridColumn>
29-
<GridColumn Field="TheName" Title="Employee Name"></GridColumn>
30-
</GridColumns>
31-
</TelerikGrid>
33+
</TelerikPager>
3234
3335
@code {
34-
public IEnumerable<object> MyData = Enumerable.Range(1, 50).Select(x => new { ID = x, TheName = "name " + x });
36+
public int TotalItems { get; set; } = 80;
37+
public int ButtonCount { get; set; } = 4;
38+
public int ItemsOnPage { get; set; } = 10;
39+
public int CurrentPage { get; set; } = 2;
3540
}
3641
````
3742

3843
>caption The result from the code snippet above
3944
40-
![](images/paging-overview.png)
45+
![basic configuration of the pager](images/pager-basic-configuration-screenshot.jpg)
46+
47+
## Features
48+
* `Class` - The CSS class that will be rendered on the main wrapping element of the Pager.
49+
* `Total` - **int** - Represents the total count of items in the pager.
50+
* `ButtonCount` - **int** - The number of pages to be visible. To take effect the `ButtonCount` must be **less** than the pages count (ButtonCount < Total / number of items on the page)
51+
* `Page` and `@bind-Page` - **int** - Represents the current page of the pager. Those parameters are respectively for one and two-way data binding. If no `Page` or `@bind-Page` are provided they will default to the first page (1).
52+
* `PageChanged` - Fires when a new page is selected (used in one-way data binding).
53+
* `PageSize` - **int** - The number of items to be presented on a pages.
54+
55+
## Examples
56+
57+
>caption Observe the behavior of the Pager with one-way data binding
58+
59+
````CSHTML
60+
@*This example showcases the usage of Page and PageChanged in conjunction*@
61+
62+
<TelerikPager Total="TotalItems"
63+
ButtonCount="ButtonCount"
64+
PageSize="ItemsOnPage"
65+
Page="CurrentPage"
66+
PageChanged="@( (int page) => PageChangedHandler(page) )">
4167
42-
>tip You can bind the values of those properties to variables in the `@code {}` section. If you want to bind the page index to a variable, you must use the `@bind-Page="@MyPageIndexVariable"` syntax.
68+
</TelerikPager>
4369
44-
Here is one way to implement a page size choice that puts all records on one page.
70+
<div class="text-info">@Result</div>
4571
46-
>caption Bind Page Size to a variable
72+
@code {
73+
public int TotalItems { get; set; } = 80;
74+
public int ButtonCount { get; set; } = 4;
75+
public int ItemsOnPage { get; set; } = 10;
76+
public int CurrentPage { get; set; } = 2;
77+
public string Result { get; set; } = String.Empty;
78+
79+
void PageChangedHandler(int page)
80+
{
81+
CurrentPage = page;
82+
Result = $"Current page: {page}";
83+
}
84+
}
85+
````
86+
>caption The result from the code snippet above
87+
88+
![config of the pager with one-way binding](images/pager-data-binding.gif)
89+
90+
>caption Observe the behavior of the Pager with two-way data binding
4791
4892
````CSHTML
49-
Dynamic page size change
50-
51-
<select @onchange=@ChangePageSize>
52-
@for (int i = 1; i < 4; i++)
53-
{
54-
<option value=@(i*10)>@(i * 10)</option>
55-
}
56-
<option value="all" selected>all</option>
57-
</select>
58-
59-
<TelerikGrid Data="@MyData" Pageable="true" PageSize="@PageSize">
60-
<GridColumns>
61-
<GridColumn Field="ID"></GridColumn>
62-
<GridColumn Field="TheName" Title="Employee Name"></GridColumn>
63-
</GridColumns>
64-
</TelerikGrid>
93+
@*This example showcases the usage of Page and PageChanged in conjunction*@
94+
95+
<TelerikPager Total="TotalItems"
96+
ButtonCount="ButtonCount"
97+
PageSize="ItemsOnPage"
98+
@bind-Page="CurrentPage">
6599
100+
</TelerikPager>
101+
<div class="text-info">Current page: @CurrentPage</div>
66102
@code {
67-
public IEnumerable<object> MyData = Enumerable.Range(1, 50).Select(x => new { ID = x, TheName = "name " + x });
68-
69-
protected int PageSize { get; set; }
70-
71-
protected void ChangePageSize(ChangeEventArgs e)
72-
{
73-
if (e.Value.ToString().ToLowerInvariant() == "all")
74-
{
75-
PageSize = MyData.Count();
76-
}
77-
else
78-
{
79-
PageSize = int.Parse(e.Value.ToString());
80-
}
81-
}
103+
public int TotalItems { get; set; } = 80;
104+
public int ButtonCount { get; set; } = 4;
105+
public int ItemsOnPage { get; set; } = 10;
106+
public int CurrentPage { get; set; } = 2;
82107
}
83108
````
109+
>caption The result from the code snippet above
110+
111+
![config of the pager with one-way binding](images/pager-data-binding.gif)
84112

85113
## See Also
86114

87-
* [Live Demo: Grid Paging](https://demos.telerik.com/blazor-ui/grid/paging)
115+
* [Live Demo: Pager Overview](https://demos.telerik.com/blazor-ui/pager/overview)
116+
* [Live Demo: Pager Integration](https://demos.telerik.com/blazor-ui/pager/integration)
117+
* [Live Demo: Pager Localization](https://demos.telerik.com/blazor-ui/pager/localization)
118+
* [Live Demo: Pager Keyboard Navigation](https://demos.telerik.com/blazor-ui/pager/keyboard-navigation)

0 commit comments

Comments
 (0)