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

RadCombobox AllItem problem

3 Answers 42 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Asa'ad
Top achievements
Rank 1
Asa'ad asked on 13 Jun 2012, 12:02 PM
Hi all,
i need to fire a javscript event when the all item is checked or unchecked???

i need to do that to be used when validating the combobox has one at least item checked...

the all item is not considered as and RadComboBoxItem as i read from the documentation...

please help....

thanks
asa'ad...

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 13 Jun 2012, 01:04 PM
Hello Asad,

If you want to perform a custom client-side action when the "CheckAllItems" checkbox is checked, then you can  attach a change() event handler at this checkbox in this way.
JS:
function onLoad(sender)
{
$telerik.$('.rcbCheckAllItemsCheckBox').change(function () {
         if (sender.get_text() == "All items checked") {
             alert(sender.get_text() + " some custom action here");
         }
     });
}

Thanks,
Shinu.
0
Asa'ad
Top achievements
Rank 1
answered on 14 Jun 2012, 08:51 AM
Hi shinu

Thanks for thr reply, i tried the code plus adding calling of  this function on the onload event of the RadComboBox

The function is called, but i noticed that the get_text() display emty string when i check the checkALLItem and when i uncheck it it gives me the All items checked....

any way, this is stange but i successed to call my javacript function....

thanks and just let me know if you have any explanation for this behavior!!!!

asa'ad.... 
0
Ivana
Telerik team
answered on 18 Jun 2012, 08:39 AM
Hi Asa'ad,

Make sure you have subscribed to the change event of the input element instead to the click event -- in which case the text from the RadComboBox's  input is taken before the checked state of 'Check All' CheckBox is changed.
Example:
function onLoad(sender) {
    $telerik.$('.rcbCheckAllItemsCheckBox').change(function () {
        alert(sender.get_text());
    });
}
<telerik:RadComboBox runat="server" ID="RadComboBox1" CheckBoxes="true" EnableCheckAllItemsCheckBox="true" OnClientLoad="onLoad">
    <Items>
        <telerik:RadComboBoxItem Text="111" />
        <telerik:RadComboBoxItem Text="222" />
        <telerik:RadComboBoxItem Text="333" />
    </Items>
</telerik:RadComboBox>

I hope this is helpful.

Kind regards,
Ivana
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.
Tags
ComboBox
Asked by
Asa'ad
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Asa'ad
Top achievements
Rank 1
Ivana
Telerik team
Share this question
or