From bcce769569a3eda1f2dbf18bba90de99af616458 Mon Sep 17 00:00:00 2001 From: "Yakali, Yagizhan Necat (ADV D EU TR AP&I PIA1)" Date: Wed, 3 May 2023 09:43:51 +0300 Subject: [PATCH] implement pagination --- README.md | 11 ++++ .../Components/Pagination/Pagination.razor | 17 ++++++ .../Components/Pagination/Pagination.razor.cs | 57 +++++++++++++++++++ 3 files changed, 85 insertions(+) create mode 100644 SiemensIXBlazor/Components/Pagination/Pagination.razor create mode 100644 SiemensIXBlazor/Components/Pagination/Pagination.razor.cs diff --git a/README.md b/README.md index 51a9a09..23b6bef 100644 --- a/README.md +++ b/README.md @@ -368,6 +368,17 @@ private void CloseModal() } ``` +- [x] Pagination + +```html + + +``` + - [x] Pill ```html diff --git a/SiemensIXBlazor/Components/Pagination/Pagination.razor b/SiemensIXBlazor/Components/Pagination/Pagination.razor new file mode 100644 index 0000000..6bcfe2f --- /dev/null +++ b/SiemensIXBlazor/Components/Pagination/Pagination.razor @@ -0,0 +1,17 @@ +@using Microsoft.JSInterop; +@inherits IXBaseComponent +@inject IJSRuntime JSRuntime + + diff --git a/SiemensIXBlazor/Components/Pagination/Pagination.razor.cs b/SiemensIXBlazor/Components/Pagination/Pagination.razor.cs new file mode 100644 index 0000000..bdf6071 --- /dev/null +++ b/SiemensIXBlazor/Components/Pagination/Pagination.razor.cs @@ -0,0 +1,57 @@ +using Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; +using SiemensIXBlazor.Interops; + +namespace SiemensIXBlazor.Components.Pagination +{ + public partial class Pagination + { + [Parameter, EditorRequired] + public string Id { get; set; } = string.Empty; + [Parameter] + public bool? Advanced { get; set; } + [Parameter] + public int? Count { get; set; } + [Parameter] + public string I18nItems { get; set; } = "Items"; + [Parameter] + public string I18nOf { get; set; } = "of"; + [Parameter] + public string I18nPage { get; set; } = "Page"; + [Parameter] + public int ItemCount { get; set; } = 15; + [Parameter] + public int SelectedPage { get; set; } = 0; + [Parameter] + public bool ShowItemCount { get; set; } = true; + [Parameter] + public EventCallback ItemCountChangedEvent { get; set; } + [Parameter] + public EventCallback PageSelectedEvent { get; set; } + + private BaseInterop _interop; + + protected async override Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) + { + _interop = new(JSRuntime); + + await _interop.AddEventListener(this, Id, "itemCountChanged", "ItemCountChanged"); + await _interop.AddEventListener(this, Id, "pageSelected", "PageSelected"); + } + } + + [JSInvokable] + public async Task ItemCountChanged(int count) + { + await ItemCountChangedEvent.InvokeAsync(count); + } + + [JSInvokable] + public async Task PageSelected(int page) + { + await PageSelectedEvent.InvokeAsync(page); + } + } +}