I would like to get an example of using Kendo RadioButtonFor control which is not working whatever way I use.
For example I am using it following way insode my Editor Template for Kendo Grid
@(Html.Kendo().RadioButtonFor(model=>model.IsMale).Value(true).Name("IsMale").Label("Male").Checked(Model.IsMale)) @(Html.Kendo().RadioButtonFor(model=>model.IsMale).Value(false).Name("IsMale").Label("Female").Checked(Model.IsMale))
It does not show correct radiobutton selected no matter isMale is true or false....
I'd appreciate any good example....
Thanks
Rizwan
7 Answers, 1 is accepted
Hello Rizwan,
When using RadioButtonFor, do not set a Name on the widgets.
The following example code runs in the examples demo application, if the radio buttons are bound to a Kendo.Mvc.Examples.Models.Product:
@(Html.Kendo().RadioButtonFor(model => model.ProductName).HtmlAttributes(new{ @name = "foobar"}).Value("Foo").Label("It is a foo"))
@(Html.Kendo().RadioButtonFor(model => model.ProductName).HtmlAttributes(new{ @name = "foobar"}).Value("Bar").Label("It is a bar"))
Both radio buttons are bound to the ProductName field, which will determine which of them is checked (if it matches their Value). The @name HtmlAttribute is used to group both radio buttons, so that only one of them is checked.
Regards,Alex Gyoshev
Telerik
Could you please let me know how to set Kendo' RadioButton using Jquery?
Suppose I have a group of 5 Kendo RadioButtons and one text box is also there. Once I click on textbox it should check one particular RadioButton, I am unable to find any answer on it.
I'd appreciate the help.
Thanks
RIzwan
Could you please let me know how to set Kendo' RadioButton using Jquery?
Suppose I have a group of 5 Kendo RadioButtons and one text box is also there. Once I click on textbox it should check one particular RadioButton, I am unable to find any answer on it.
I'd appreciate the help.
Thanks
RIzwan
Hello Rizwan,
You can toggle the radio button by setting its checked property:
$("[type=radio]").eq(2).prop("checked", true);
Regards,Alex Gyoshev
Telerik
Thanks for the reply, could you please elaborate what is .eq in it?
I tried it but its not working, let me tell you the scenario once more.
I have 6 radio buttons and last one is called OTHER, for which user has to provide some description in case use selects OTHER.
But I also want whenever user clicks on that textbox dedicated to provide details for OTHER option, the OTHER radioButton should programmaticaslly be sleected knowlingly user is clicked inside that textbox to provde details for the option OTHER.
Thanks
Rizwan
Hello Rizwan,
The eq method is part of jQuery -- see its documentation. As for your use case, you need to substitute the jQuery selector and eq method call with some way of getting the "other" radio button.
Regards,Alex Gyoshev
Telerik