RadCombobox AllItem problem

4 posts, 0 answers
  1. Asa'ad
    Asa'ad avatar
    77 posts
    Member since:
    May 2011

    Posted 13 Jun 2012 Link to this post

    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...
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 13 Jun 2012 Link to this post

    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.
  3. Asa'ad
    Asa'ad avatar
    77 posts
    Member since:
    May 2011

    Posted 14 Jun 2012 Link to this post

    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.... 
  4. Ivana
    Admin
    Ivana avatar
    657 posts

    Posted 18 Jun 2012 Link to this post

    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.
Back to Top