Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Paging Ui Example positions column values incorrectly #298

Closed
chigivigi opened this issue Jan 20, 2023 · 2 comments 路 Fixed by #306
Closed

Custom Paging Ui Example positions column values incorrectly #298

chigivigi opened this issue Jan 20, 2023 · 2 comments 路 Fixed by #306

Comments

@chigivigi
Copy link

馃悰 Bug Report

On the Blazor fast demo page under the Datagrid examples exists a Custom paging UI Example.
Inside the example the number of the pages inside the Datagrid is displayed as buttons.
When accessing the data on another page the the positions of column values are incorrect. All column values are displayed on the far right and squished together.

image

image

馃捇 Repro or Code Sample

The code snipped are copied from the demo page:
Razor:


<div class="grid">
    <FluentDataGrid RowsData="@itemsQueryable" Pagination="@pagination">
        <PropertyColumn Property="@(c => c.Name)" Sortable="true" Class="country-name" />
        <PropertyColumn Property="@(c => c.Medals.Gold)" Sortable="true" Align="Align.Right" />
        <PropertyColumn Property="@(c => c.Medals.Silver)" Sortable="true" Align="Align.Right" />
        <PropertyColumn Property="@(c => c.Medals.Bronze)" Sortable="true" Align="Align.Right" />
    </FluentDataGrid>
</div>

<div class="page-buttons">
    Page:
    @if (pagination.TotalItemCount.HasValue)
    {
        for (var pageIndex = 0; pageIndex <= pagination.LastPageIndex; pageIndex++)
        {
            var capturedIndex = pageIndex;
            <FluentButton @onclick="@(() => GoToPageAsync(capturedIndex))"
                    Appearance="@PageButtonAppearance(capturedIndex)"
                    aria-current="@AriaCurrentValue(capturedIndex)"
                  aria-label="@AriaLabel(pageIndex + 1)">
                @(capturedIndex + 1)
            </FluentButton>
        }
    }
</div>

@code {
    PaginationState pagination = new PaginationState { ItemsPerPage = 10 };
    IQueryable<Country>? itemsQueryable;

    protected override async Task OnInitializedAsync()
    {
        itemsQueryable = (await Data.GetCountriesAsync()).AsQueryable();
        pagination.TotalItemCountChanged += (sender, eventArgs) => StateHasChanged();
    }

    private async Task GoToPageAsync(int pageIndex)
    {
        await pagination.SetCurrentPageIndexAsync(pageIndex);
    }

    private Appearance PageButtonAppearance(int pageIndex)
        => pagination.CurrentPageIndex == pageIndex ? Appearance.Accent : Appearance.Neutral;

    private string? AriaCurrentValue(int pageIndex)
        => pagination.CurrentPageIndex == pageIndex ? "page" : null;

    private string AriaLabel(int pageIndex)
        => $"Go to page {pageIndex}";
}

CSS:

/* Fix height and enable scrolling */
.grid {
    height: 24.5rem;
    overflow-y: auto;
}


/* Style the custom page links*/
.page-buttons {
    margin: 1rem 0;
    align-items: center;
}

    .page-buttons button {
        background: #d6d7d8;
        color: black;
        padding: 0.25rem 0.75rem;
        border-radius: 0.4rem;
        transition: transform 0.3s ease-out;
        margin: 0.25rem;
    }

        .page-buttons button:active {
            background: #a7c1ff !important;
            color: white;
            transform: scale(0.95) translateY(-0.15rem);
            transition-duration: 0.05s;
        }

        .page-buttons button:hover:not(.current) {
            background: #c0c9dc;
        }

        .page-buttons button.current {
            background: #3771f4;
            color: white;
        }

馃 Expected Behavior

The column values should be aligned with the column title.

馃槸 Current Behavior

When the page in the Datagrid is changed the values in the column are no longer aligned with column title and are squished together on the right side of the Datagrid .

馃敠 Context

When changing the page inside the Datagrid the displayed row values are squished together and for multiple rows. It makes it more difficult to associate the values to their respective rows and makes the data harder to read and use the information.

馃實 Your Environment

Windows 11
net6.0 framework
visual studio 2022
Microsoft Edge latest version

@chigivigi
Copy link
Author

vnbaaij added a commit that referenced this issue Jan 26, 2023
DemoSection: add AdditionalFiles parameter
DataGrid: Fix #298
@vnbaaij vnbaaij mentioned this issue Jan 26, 2023
6 tasks
@vnbaaij
Copy link
Collaborator

vnbaaij commented Jan 26, 2023

Check fixed version here: https://brave-cliff-0c0c93310-302.centralus.azurestaticapps.net/DataGrid

vnbaaij added a commit that referenced this issue Jan 31, 2023
vnbaaij added a commit that referenced this issue Jan 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants