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

Make sure SelectedRow/SelectedRows changes are always notificated to DatagridRow #3457

Merged

Conversation

David-Moreira
Copy link
Contributor

Make sure SelectedRow/SelectedRows changes are always notificated to DatagridRow by re-setting them up as parameters.

I think there was one more issue related to this but I can't seem to find it now.
Closes #3386

Code used for testing:
(Basically select rows, then mutate the SelectedRows... see if it propagates successfully.)

<DataGrid 
@ref="dataGridRef"
            TItem="string" Data="@dataList" Narrow="true" FixedHeader="true" Virtualize="false"
          VirtualizeOptions="@(new Blazorise.DataGrid.Configuration.VirtualizeOptions() { DataGridHeight="calc(-8px + 70vh) !important", DataGridMaxHeight="calc(-8px + 70vh) !important" })"
          Striped="true" Bordered="true" Filterable="true" Sortable="false" SelectionMode="DataGridSelectionMode.Multiple"
          Responsive="true"
          SelectedRows="@myList"
          SelectedRowsChanged="@AddOrRemoveMyList">
    <DataGridColumn TItem="string" Caption="No">
        <DisplayTemplate>
            @context
        </DisplayTemplate>
    </DataGridColumn>
</DataGrid>
<Button Color="Color.Danger" Clicked="@ResetSelection">Reset</Button>
@String.Join(',' , myList)
@code {
    private DataGrid<string> dataGridRef;
    private List<string> dataList = new List<string>() { "a", "b", "c", "d", "e", "f" };
    private List<string> myList = new List<string>();

    private void AddOrRemoveMyList(List<string> someList)
    {
        myList = someList;
        StateHasChanged();
    }

    private void ResetSelection()
    {
        myList = new List<string>();
        //myList.Clear();
        StateHasChanged();
    }
}

…DatagridRow by setting them up as parameters.
@David-Moreira David-Moreira requested a review from stsrki February 16, 2022 00:36
@stsrki stsrki merged commit abc6aeb into rel-0.9.5 Feb 16, 2022
@stsrki stsrki deleted the rel-0.9.5-DataGridRowSelectedRowsParameterForNotification branch February 16, 2022 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants