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

DataGridSelectColumn: SetValue, consider ValueField if set #5080

Merged

Conversation

David-Moreira
Copy link
Contributor

@David-Moreira David-Moreira commented Oct 17, 2023

Code to test:

<DataGrid TItem="Employee" Data="@employeeList" PageSize="5" Responsive Editable Filterable EditMode="DataGridEditMode.Popup">
     <DataGridSelectColumn TItem="Employee" Field="@nameof( Employee.Role )" Caption="Gender" Editable
                           Data="RolesNamesSource" ValueField="(x) => ((UsersRoles)Enum.Parse(typeof(UsersRoles), (string)x))" TextField="(x) => (string)x" />
     <DataGridCommandColumn />
 </DataGrid>

 @code {

    private List<Employee> employeeList = new List<Employee>() { new Employee( UsersRoles.Standard ), new Employee( UsersRoles.Premium ), new Employee( UsersRoles.Admin ) };
    private List<string> RolesNamesSource = Enum.GetNames( typeof( UsersRoles ) ).ToList();

    protected override void OnInitialized()
    {

        base.OnInitialized();

    }

    class Employee
    {
        public Employee( UsersRoles role )
        {
            Role = role;
        }

        public UsersRoles Role { get; set; }
    }

    enum UsersRoles
    {
        Standard,
        Premium,
        Admin
    }

}

@David-Moreira David-Moreira linked an issue Oct 17, 2023 that may be closed by this pull request
@David-Moreira David-Moreira requested a review from stsrki October 17, 2023 17:23
@stsrki stsrki changed the title DataGridSelectColumn | SetValue, consider ValueField if set DataGridSelectColumn: SetValue, consider ValueField if set Oct 18, 2023
@stsrki stsrki merged commit a1519d3 into rel-1.3 Oct 18, 2023
2 checks passed
@stsrki stsrki deleted the 5073-bind-datagridselectcolumn-to-an-enum-field-cast-error branch October 18, 2023 09:16
@github-actions github-actions bot locked and limited conversation to collaborators Oct 18, 2023
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.

Bind DatagridSelectColumn to an Enum Field (cast error)
2 participants