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

DataGrid: DataGridSelectEdit | Always refresh selectItems if Data count has changed #5868

Conversation

David-Moreira
Copy link
Contributor

Testing Code :

@page "/"
@inject IVersionProvider VersionProvider
<DataGrid TItem="Employee"
Data="@employeeList"
@bind-SelectedRow="@selectedEmployee"
Responsive Filterable>
    <DataGridCommandColumn />
    <DataGridColumn Field="@nameof(Employee.FirstName)" Caption="First Name" Editable />
    <DataGridColumn Field="@nameof(Employee.LastName)" Caption="Last Name" Editable />
        <DataGridSelectColumn TItem="Employee" Field="@nameof( Employee.Category )" Caption="Category" Editable
        Data="employeeCategories" ValueField="(x) => ((EmployeeCategory)x).Id.ToString()" TextField="(x) => ((EmployeeCategory)x).Name" />

</DataGrid>


@code {
    private List<Employee> employeeList;
    public static List<EmployeeCategory> employeeCategories = new();
    private Employee selectedEmployee;
    protected override async Task OnInitializedAsync()
    {
        employeeCategories.Clear();

        employeeCategories.Add(new EmployeeCategory() { Name = "test1", Id = Guid.NewGuid() }); // is loaded into the dropdown
        await Task.Delay(1000);
        employeeCategories.Add(new EmployeeCategory() { Name = "test2", Id = Guid.NewGuid() }); // isn't loaded into the dropdown

        await base.OnInitializedAsync();
    }

    public class Employee
    {
        public Guid Id { get; set; }
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public string Email { get; set; }
        public int Salary { get; set; }
        public EmployeeCategory Category { get; set; }
    }

    public class EmployeeCategory
    {
        public Guid Id { get; set; }
        public string Name { get; set; }
    }
}

@David-Moreira David-Moreira marked this pull request as ready for review November 23, 2024 11:34
@David-Moreira David-Moreira linked an issue Nov 23, 2024 that may be closed by this pull request
@stsrki stsrki changed the title DataGrid : DataGridSelectEdit | Always refresh selectItems if Data count has changed DataGrid: DataGridSelectEdit | Always refresh selectItems if Data count has changed Nov 25, 2024
@stsrki stsrki merged commit 25e6d64 into rel-1.6 Nov 25, 2024
2 checks passed
@stsrki stsrki deleted the 5835-bug-datagridselectcolumn-dataloading-breaks-on-async-methods branch November 25, 2024 09:46
@github-actions github-actions bot locked and limited conversation to collaborators Nov 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: DataGridSelectColumn dataloading breaks on async methods
2 participants