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

combo box with checkboxes, check the checkbox when text is clicked on?

2 Answers 80 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 22 May 2012, 06:52 PM
I have a radcomboBox, with CheckBoxes set to true. How can I get it so that when a user clicks on the text, it also checks/unchecks the checkbox?

<telerik:RadComboBox
	ID="CustomerComboBox" runat="server" 
	Width="300px" Height="140px"
	EmptyMessage="Type a customer name"
	DataTextField="CustomerName" 
        DataValueField="CustomerId"
	CheckBoxes="True"  
        OnClientItemChecked="ReportSystem.CustomerComboBox_Checked"
	AllowCustomText="False"
	MarkFirstMatch = "True"
	OnClientKeyPressing="ReportSystem.OnClientKeyPressing"
	>
</telerik:RadComboBox>

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 23 May 2012, 06:07 AM
Hi Chris,

Try the following jquery to achieve your scenario.

Jquery:
<script type="text/javascript" >
function pageLoad()
{
        $('.rcbItem').click(checkBoxItemClicked);
}
 
function checkBoxItemClicked(sender)
{
        var checkBox = $(sender.target).find(':checkbox');
        if (checkBox.attr("checked") == true)
        {
            checkBox.attr("checked", false);
        }
        else
        {
            checkBox.attr("checked", true);
        }
}
</script>

Hope this helps.

Thanks,
Princy.
0
Chris
Top achievements
Rank 1
answered on 23 May 2012, 07:05 PM
That works thanks, did have to do one additional thing, and change one thing to keep everything synced:
$('.rcbItem').click(function (sender) {
                           var checkBox = $(sender.target).find(':checkbox');
                            if (checkBox.is(':checked'))
                            {
                                checkBox.attr("checked"false);
                            }
                            else
                            {
                                checkBox.attr("checked"true);
                            }
                           $(checkBox).trigger("click");
                       });
Tags
ComboBox
Asked by
Chris
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Chris
Top achievements
Rank 1
Share this question
or