Setting a RadButton with set_checked

5 posts, 1 answers
  1. RSI
    RSI avatar
    82 posts
    Member since:
    Nov 2011

    Posted 28 Nov 2011 Link to this post

    Hello Telerik!

    We have a page that uses a couple RadButtons as check boxes. A grid row is selected and it fills in controls with data on the page. Other controls work fine but the RadButton will not accept the Boolean value for setting it checked. Once the data is read and then rendered to the controls the RadButton's are always go unchecked to checked.

    Here is the control in ASPX
    <telerik:RadButton runat="server" ID="RadButtonIsFemale" Text="Female?" ButtonType="ToggleButton" AutoPostBack="false" ToggleType="CheckBox"></telerik:RadButton>

    And the RadGrid calls a Javascript function RowSelected that updates the controls with grid data.

    function RowSelected(sender, args) {
    var myRadGrid = sender;
            var myMasterTable = myRadGrid.get_masterTableView();
            var myName = myMasterTable.get_selectedItems()[0].getDataKeyValue('Name');
    $find("<%= RadTextBoxName.ClientID %>").set_value(myName);
    ...
    ...
    ...
    var myIsFemale = myMasterTable.get_selectedItems()[0].getDataKeyValue('IsFemale');
    $find("<%= RadButtonIsFemale.ClientID %>").set_checked(myIsFemale);
    }

    The bold line above always just sets it to True - I have validated the data, so False and True values are definitely set to 'IsFemale', but it doesn't toggle the check. Is there a different property that needs to be set?

    Thanks!
    SDI

  2. Answer
    Slav
    Admin
    Slav avatar
    1356 posts

    Posted 01 Dec 2011 Link to this post

    Hi Brian,

    Please find attached a sample page that demonstrates changing the checked status of a CheckBox RadButton. You can verify that the button control is checked and unchecked correctly, depending on the Boolean value, passed to the client method set_checked.

    My suggestion is to check the value that is returned from myMasterTable.get_selectedItems()[0].getDataKeyValue('IsFemale') as most probably it is causing the unexpected behavior. Please refer also to this article, explaining the principle for setting the value of a Boolean object. Note that if you pass a string "false" the value of the variable will be true.

    I hope that helps.

    Greetings,
    Slav
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. RSI
    RSI avatar
    82 posts
    Member since:
    Nov 2011

    Posted 01 Dec 2011 Link to this post

    Ha! Yes that is right, ya know you get so caught up in coding you forget about how js works. Its a wee bit different.

    Thanks a bunch for the reminder! 

    Hey on another note, can I get back a tooltip of a node in js? Like myRadTreeNode.get_Tooltip? I see some documentation for the most of the properties of your controls in js, but not all. Do you have a "cheat sheet" of every control and their callable properties in js?

    Thanks again!
    SDI
  5. Slav
    Admin
    Slav avatar
    1356 posts

    Posted 06 Dec 2011 Link to this post

    Hi Brian,

    Yes, the client object of the RadButton exposes a method get_toolTip(), which gets the text displayed when the mouse pointer hovers over the button control. There are more client methods that allow easy interaction with the RadButton, the full list is available in the help article Client-side basics.

    Most of the RadControls for ASP.NET AJAX have similar lists of usable client-side methods, which can be found in the RadControls section of the RadControls for ASP.NET AJAX Documentation under the specific node for every control.

    Regards,
    Slav
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  6. Sally
    Sally avatar
    1 posts
    Member since:
    Dec 2011

    Posted 06 Jan 2012 Link to this post

    hi, Thanks a bunch for the reminder! i think it will be come in handy next time i encountered this problem
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017