Skip to content

API proposal for CloseColumnOptionsAsync #61135

Closed
@javiercn

Description

@javiercn

Overview and Motivation

Developers trying to hide the currently displayed column options don't have a way to do so.

Proposed API

namespace Microsoft.AspNetCore.Components.QuickGrid
{
    public partial class QuickGrid<TGridItem>
    {
        /// <summary>
        /// Adds the ability to programmatically close QuickGrid's column options UI.
        /// </summary>
        public System.Threading.Tasks.Task CloseColumnOptionsAsync()
        {
            // ...existing code...
        }
    }
}

Usage Examples

<h3>Sample QuickGrid Component</h3>

<div id="grid">
    <QuickGrid Items="@FilteredPeople" Pagination="@pagination" RowClass="HighlightJulie" custom-attrib="somevalue" class="custom-class-attrib">
    <QuickGrid @ref="@quickGridRef" Items="@FilteredPeople" Pagination="@pagination" RowClass="HighlightJulie" custom-attrib="somevalue" class="custom-class-attrib">
        <PropertyColumn Property="@(p => p.PersonId)" Sortable="true" />
        <PropertyColumn Property="@(p => p.firstName)" Sortable="true">
            <ColumnOptions>
                <div class="search-box">
                    <input type="search" autofocus @bind="firstNameFilter" @bind:event="oninput" placeholder="First name..." />
                </div>
                <button type="button" id="close-column-options" @onclick="@(() => quickGridRef.CloseColumnOptionsAsync())">
                    Close Column Options
                </button>
            </ColumnOptions>
        </PropertyColumn>
        <PropertyColumn Property="@(p => p.lastName)" Sortable="true" />
        record Person(int PersonId, string firstName, string lastName, DateOnly BirthDate);
        PaginationState pagination = new PaginationState { ItemsPerPage = 10 };
        string firstNameFilter;
        QuickGrid<Person> quickGridRef;

        int ComputeAge(DateOnly birthDate)
            => DateTime.Now.Year - birthDate.Year - (birthDate.DayOfYear < DateTime.Now.DayOfYear ? 0 : 1);
</div>

Alternative Designs

Risk Considerations

Making CloseColumnOptionsAsync public could introduce unintended side effects if used in unanticipated ways. Test changes are recommended.

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-approvedAPI was approved in API review, it can be implementedarea-blazorIncludes: Blazor, Razor Components

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions