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

Kendo Radio Buttons

7 Answers 1440 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Rizwan
Top achievements
Rank 1
Rizwan asked on 28 Jan 2016, 03:13 PM

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

Sort by
0
Accepted
Alex Gyoshev
Telerik team
answered on 29 Jan 2016, 01:42 PM

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
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Rizwan
Top achievements
Rank 1
answered on 29 Jan 2016, 02:45 PM
Thanks for your help, it worked perfectly.
0
Rizwan
Top achievements
Rank 1
answered on 17 Feb 2016, 10:16 PM
Hi

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
0
Rizwan
Top achievements
Rank 1
answered on 17 Feb 2016, 10:17 PM
Hi ALex

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
0
Alex Gyoshev
Telerik team
answered on 18 Feb 2016, 02:15 PM

Hello Rizwan,

You can toggle the radio button by setting its checked property:

   $("[type=radio]").eq(2).prop("checked", true);

Regards,
Alex Gyoshev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Rizwan
Top achievements
Rank 1
answered on 18 Feb 2016, 02:51 PM
Alex
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
0
Alex Gyoshev
Telerik team
answered on 22 Feb 2016, 07:08 AM

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
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
PanelBar
Asked by
Rizwan
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Rizwan
Top achievements
Rank 1
Share this question
or