Fire a JavaScript when Check All is cliked

5 posts, 1 answers
  1. RJ
    RJ avatar
    395 posts
    Member since:
    Oct 2006

    Posted 03 Aug 2012 Link to this post

    Hi,

    How can I fire a Javascript when Check All is cliked. Both OnClientItemChecked and OnClientItemChecking dont work when I click Check All checkbox in my dropdown.

    Thanks,
    RJ
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 06 Aug 2012 Link to this post

    Hi,

    Try the following javascript to raise event on clicking Check All checkbox.
    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. RJ
    RJ avatar
    395 posts
    Member since:
    Oct 2006

    Posted 07 Aug 2012 Link to this post

    Hi Shinu,
    Where should I attach the onLoad? I added OnclientLoad="onLoad" to my Radcombo but it didnt work. Also I'm useing Masterpage on this.
    Thanks,
    RJ
  4. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 08 Aug 2012 Link to this post

    Hi RJ,

    Unfortunately I couldn't replicate the issue. Here is the code that I tried based on your scenario which works as expected at my end.

    ASPX:
    <telerik:RadComboBox ID="RadComboBox1" runat="server" EnableCheckAllItemsCheckBox="true" CheckBoxes="true" OnClientLoad="onLoad" >
      <Items>
            ............
       </Items>
    </telerik:RadComboBox>

    Another approach is that you can raise the event as follows.

    Javascript:
    <script type="text/javascript">
    $telerik.$(
    '.rcbCheckAllItemsCheckBox').change(function () {
                   // Your code
                });
    </script>
  5. RJ
    RJ avatar
    395 posts
    Member since:
    Oct 2006

    Posted 08 Aug 2012 Link to this post

    Hi Shinu,
    new code wont work, but when I tried the first code again it worked now. My bad, I have localized AllItemsCheckedString thats why it didnt work the first time... Thank you so much. 
Back to Top