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

Setting a RadButton with set_checked

4 Answers 366 Views
Button
This is a migrated thread and some comments may be shown as answers.
SDI
Top achievements
Rank 1
SDI asked on 29 Nov 2011, 01:47 AM
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

4 Answers, 1 is accepted

Sort by
0
Accepted
Slav
Telerik team
answered on 01 Dec 2011, 03:39 PM
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
0
SDI
Top achievements
Rank 1
answered on 01 Dec 2011, 10:30 PM
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
0
Slav
Telerik team
answered on 06 Dec 2011, 02:15 PM
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
0
Sally
Top achievements
Rank 1
answered on 06 Jan 2012, 09:30 AM
hi, Thanks a bunch for the reminder! i think it will be come in handy next time i encountered this problem
Tags
Button
Asked by
SDI
Top achievements
Rank 1
Answers by
Slav
Telerik team
SDI
Top achievements
Rank 1
Sally
Top achievements
Rank 1
Share this question
or