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

fix: SelectAll State in DataGrid #2163

Closed
iguanaware opened this issue Jun 6, 2024 · 0 comments · Fixed by #2164
Closed

fix: SelectAll State in DataGrid #2163

iguanaware opened this issue Jun 6, 2024 · 0 comments · Fixed by #2164
Labels
triage New issue. Needs to be looked at

Comments

@iguanaware
Copy link

🐛 Bug Report

BTW: In the Demo Site toggling between settings can also reproduce it.
ccc Screenshot 2024-06-06 134739

After removing rows from datagrid the select all state remains unaffected.

Before Removing content from the collection
AA Screenshot 2024-06-06 132744

After Removing content
bbb Screenshot 2024-06-06 132849

💻 Repro or Code Sample

The only way we were able to get it to update was for force calling the setter

<FluentDataGrid TGridItem="CollectionWrapper" Items="@FilteredItems" Pagination="@pagination">
    <SelectColumn @ref="selectColumn" TGridItem="CollectionWrapper" SelectMode="DataGridSelectMode.Multiple" @bind-SelectedItems="@SelectedItems" />
        private async Task DeleteCollectionsAsync(MouseEventArgs mouseEventArgs)
        {
            var itemstodelete = this.SelectedItems
                .Select(x => x.designCollectionDTO.DesignCollectionUUID)
                .ToArray();

            await this.CollectionService.RemoveDesignCollectionsAsync(itemstodelete, CancellationToken.None);

       
            this.selectColumn.SelectedItems = [];
        }

this.selectColumn.SelectedItems is not recommend BL0005 Component Parameter outside of the component

public class SelectColumn<TGridItem> : ColumnBase<TGridItem>
...
    /// <summary>
    /// Gets or sets the list of selected items.
    /// </summary>
    [Parameter]
    public IEnumerable<TGridItem> SelectedItems
    {
        get => _selectedItems;
        set
        {
            if (_selectedItems != value)
            {
                _selectedItems.Clear();
                _selectedItems.AddRange(value);
            }
        }
    }

Note: items and FilteredItems are update in the background followed by an InvokeAsync(StateHasChanged)

🤔 Expected Behavior

Provide a manual way to reset/rebuild the Selected Item state.

🌍 Your Environment

		<PackageReference Include="Microsoft.FluentUI.AspNetCore.Components" Version="4.7.2" />
		<PackageReference Include="Microsoft.FluentUI.AspNetCore.Components.Icons" Version="4.7.0" />
@microsoft-github-policy-service microsoft-github-policy-service bot added the triage New issue. Needs to be looked at label Jun 6, 2024
vnbaaij added a commit that referenced this issue Jun 7, 2024
vnbaaij added a commit that referenced this issue Jun 7, 2024
* Fix #2163 by adding ClearSelection method

* Add ClearSelectionAsync
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage New issue. Needs to be looked at
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant