This is a migrated thread and some comments may be shown as answers.

GridEditMode.PopUp Template not working for HTML.Kendo().RadioButtonFor

1 Answer 218 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Reeba
Top achievements
Rank 1
Reeba asked on 15 Dec 2020, 06:04 PM

I have a kendo grid which pops up a custom template. All the fields are working correctly except the kendo button. I need it to be checked by default when the page pops up, but that does not happen when I use @Html.RadioButtonFor but it does get to the javascript.

If I use  @Html.Kendo().RadioButtonFor it does not get checked by default nor does it hit the javascript.

Is there something not right with the way I am calling the button

 <div class="form-group row">
            @Html.HiddenFor(model => model.MessageType)
            <div class="col-sm-4 k-edit-field">
                @Html.RadioButtonFor(model => model.MessageType, new { Checked = "checked", @id = "rad_system" })<span class="system_message">System Outage</span>

            </div>
            <div class="col-sm-4 k-edit-field">
                @Html.RadioButtonFor(model => model.MessageType, new { id = "rad_system_maintenance" })<span class="system_maintenance_message">System Maintenance</span>

            </div>
            <div class="col-sm-4 k-edit-field ">
                @Html.RadioButtonFor(model => model.MessageType, new { @id = "rad_news" })<span class="news_message">News</span>


            </div>

        </div>

 

1 Answer, 1 is accepted

Sort by
0
Alex Hajigeorgieva
Telerik team
answered on 17 Dec 2020, 03:29 PM

Hi, Reeba,

The UI for ASP.NET MVC Kendo RadioButtonFor editor works well when I tested it in a custom popup. The key is to ensure that the Value() which is in the editor will match the value from the model. When this happens, the corresponding radio will be checked automatically:

https://docs.telerik.com/aspnet-mvc/html-helpers/navigation/radiobutton/model-binding

In the example, I used the following model definition:

//model
public string MessageType { get; set; }

// editor
<div class="k-edit-label">MessageType</div>
<div class="k-edit-field">
    <div>
        @Html.Kendo().RadioButtonFor(model => model.MessageType).Value("System Maintenance").Label("System Maintenance")
    </div>
    <div>
        @Html.Kendo().RadioButtonFor(model => model.MessageType).Value("System Outage").Label("System Outage")
    </div>
    <div>
        @Html.Kendo().RadioButtonFor(model => model.MessageType).Value("News").Label("News")
    </div>
</div>

And the grid model itself has one of the three possible values so that when it is opened for editing, it automatically finds the radio button with its matching value and checks it.

Let me know in case you have further questions.

Regards,
Alex Hajigeorgieva
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
Reeba
Top achievements
Rank 1
Answers by
Alex Hajigeorgieva
Telerik team
Share this question
or