Kendo Radio Buttons

8 posts, 1 answers
  1. Rizwan
    Rizwan avatar
    11 posts
    Member since:
    Sep 2015

    Posted 28 Jan Link to this post

    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

  2. Answer
    Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2500 posts

    Posted 29 Jan Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
  4. Rizwan
    Rizwan avatar
    11 posts
    Member since:
    Sep 2015

    Posted 29 Jan in reply to Alex Gyoshev Link to this post

    Thanks for your help, it worked perfectly.
  5. Rizwan
    Rizwan avatar
    11 posts
    Member since:
    Sep 2015

    Posted 17 Feb in reply to Rizwan Link to this post

    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
  6. Rizwan
    Rizwan avatar
    11 posts
    Member since:
    Sep 2015

    Posted 17 Feb in reply to Alex Gyoshev Link to this post

    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
  7. Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2500 posts

    Posted 18 Feb Link to this post

    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!
     
  8. Rizwan
    Rizwan avatar
    11 posts
    Member since:
    Sep 2015

    Posted 18 Feb in reply to Alex Gyoshev Link to this post

    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
  9. Alex Gyoshev
    Admin
    Alex Gyoshev avatar
    2500 posts

    Posted 22 Feb Link to this post

    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!
     
Back to Top
Kendo UI is VS 2017 Ready