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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API proposal for CloseColumnOptionsAsync #61135

Closed
javiercn opened this issue Mar 24, 2025 · 1 comment · Fixed by #61154
Closed

API proposal for CloseColumnOptionsAsync #61135

javiercn opened this issue Mar 24, 2025 · 1 comment · Fixed by #61154
Labels
api-approved API was approved in API review, it can be implemented area-blazor Includes: Blazor, Razor Components
Milestone

Comments

@javiercn
Copy link
Member

javiercn commented Mar 24, 2025

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.

@javiercn javiercn added the api-suggestion Early API idea and discussion, it is NOT ready for implementation label Mar 24, 2025
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-blazor Includes: Blazor, Razor Components label Mar 24, 2025
@halter73
Copy link
Member

API Review Notes:

  • Does OpenColumnOptionsAsync exist?
    • Basically, ShowColumnOptionsAsync does.
  • Should we call it HideColumnOptionsAsync then? Yes
  • Does it need to be async?
    • Not really, but it might be useful later.
    • ShowColumnOptionsAsync is also async even though it just returns CompletedTask today like this API.
  • Do you need to be able to select the column to close the options for?
    • No. Only one column options can be open at time.

Note: We renamed the method to start with "Hide" instead of "Open"

API Approved!

namespace Microsoft.AspNetCore.Components.QuickGrid;

public partial class QuickGrid<TGridItem>
{
+    public Task HideColumnOptionsAsync();
}

@halter73 halter73 added api-approved API was approved in API review, it can be implemented and removed api-suggestion Early API idea and discussion, it is NOT ready for implementation labels Mar 24, 2025
@javiercn javiercn added this to the 10.0-preview4 milestone Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-approved API was approved in API review, it can be implemented area-blazor Includes: Blazor, Razor Components
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants