Skip to content

Failing RadioButton validation when used in Grid's popup EditorTemplate #6386

@DRLFR

Description

@DRLFR

Bug report

RadioButton validation failed when used with Template (Popup) inside Grid

Reproduction of the problem

Add new item to the grid ( select a radiobutton then Update.)

Model :

    public class TestViewModel
    {
        public int Id { get; set; }
        [Required]
        public TypeTraitementTest Traitement { get; set; }
        public IEnumerable<SelectListItem> TraitementSelectListItem =>
            new List<TypeTraitementTest> { TypeTraitementTest.Plein, TypeTraitementTest.Demi, TypeTraitementTest.Sans }
                .Select(g => new SelectListItem { Text = g.ToString(), Value = ((int) g).ToString() });
    }

    public enum TypeTraitementTest {Plein = 1, Demi = 2,Sans = 3,}

Page with Grid :

        <div class="form-group row">
            <div class="col-12">
                @(Html.Kendo().Grid<TestViewModel>()
            .Name("Table")
            .Columns(c =>
            {
                c.Bound(m => m.Traitement);
            })
            .ToolBar(t => t.Create())
            .Editable(ed => ed
                .Mode(GridEditMode.PopUp)
                .TemplateName("TestTemplate")
            )
            .NoRecords()
            .DataSource(ds =>
            {
                ds.Ajax()
                    .Read(read => read.Action("TestLecture", "Test"))
                    .Create(create => create.Action("TestCreation", "Test"))
                    .Model(p =>
                    {
                        p.Id(m => m.Id);
                    });
            })
            .Pageable()
            )
            </div>
        </div>

EditorTemplate ("TestTemplate") :

@model TestViewModel

    <div class="form-group">
        @foreach (var item in Model.TraitementSelectListItem)
        {
            @(Html.Kendo().RadioButtonFor(m => m.Traitement).Label(item.Text).Value(item.Value)
                .Checked(((int)Model.Traitement).ToString() == item.Value))<br />
        }
        @Html.ValidationMessageFor(m => m.Traitement)
    </div>

Expected/desired behavior

New item should be created (validation) when a Update is clicked
(Worked with Kendo UI version 2020.3.1021)

Environment

  • Kendo UI version: 2021.1.330
  • jQuery version: 3.5.1
  • Browser: all

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions