How to call Server side event on radcombobox closed (EnableCheckAllItemsCheckBox="true")

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

    Posted 02 Aug 2012 Link to this post

    Hi

    I have several radcombos with EnableCheckAllItemsCheckBox="true" and all dropdowns are "all checked" by default, but once you uncheck items on the first radcombo, datas on other radcombos will be changed as well during onradcombobox closed/onblur/onlost focus/etc. How can I call server side event during dropdownclosed with checked items will be the filter for populating other dropdowns. Please note that server side event will fire only when there are changes made with the first dropdown so that it would not make same query to the database with just same values in return (is this possible?)  

    Thanks in advance,
    RJ
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 03 Aug 2012 Link to this post

    Hello,

    You can add a hidden field to track the changes in the combobox and raise a button click based on the hidden field value. Here is the sample code.

    ASPX:
    <telerik:RadComboBox ID="RadComboBox1" runat="server" CheckBoxes="true" OnClientDropDownClosed="OnClientDropDownClosed" OnClientItemChecked= "OnClientItemChecked" >
      <Items>
          ............     
      </Items>
    </telerik:RadComboBox>
     
    <asp:Button ID="Button1" runat="server" onclick="Button1_Click" CssClass="HiddenButton" />
    <asp:HiddenField ID="HiddenField1" runat="server" />

    Javascript:
    <script type="text/javascript">
    function OnClientDropDownClosed(sender, args)
    {
     if (document.getElementById("HiddenField1").value == 1)
     {
      document.getElementById("HiddenField1").value = 0;
      document.getElementById("Button1").click();
     }
    }
    function OnClientItemChecked(sender, args)
    {
     document.getElementById("HiddenField1").value = 1;
    }
    </script>

    C#:
    protected void Button1_Click(object sender, EventArgs e)
     {
      //Your Code
     }

    Hope this helps.

    Thanks,
    Princy.
  3. RJ
    RJ avatar
    395 posts
    Member since:
    Oct 2006

    Posted 03 Aug 2012 Link to this post

    Thanks Princy it works like a charm...

    though there has been a bit of problem when your clicking CheckAll. The OnClientItemChecked wont fire if you click Check All, so if your previous filter was from several items checked and you click on check all and close the dropdown the server event wont fire coz the hidden text was not updated when user clicks on check all.

    Thanks again,
    RJ
  4. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 06 Aug 2012 Link to this post

    Hi,

    Try the following Jquery to update the hiiddenfield value on clicking CheckAll Items Checkbox.

    Javascript:
    <script type="text/javascript">
    $("#RadComboBox3_DropDown .rcbCheckAllItemsCheckBox").click(function () {
      document.getElementById("HiddenField1").value = 1;
     });
    </script>

    Thanks,
    Princy.
  5. RJ
    RJ avatar
    395 posts
    Member since:
    Oct 2006

    Posted 07 Aug 2012 Link to this post

    I'm having an error to jquery sripts-> The value of the property '$' is null or undefined, not a Function object
    Seems like it cant find this RadComboBox3_DropDown .rcbCheckAllItemsCheckBox on the page
    Already change this to:
    RadComboBox3_DropDown.rcbCheckAllItemsCheckBox
    RadComboBox1_DropDown.rcbCheckAllItemsCheckBox
    RadComboBox0_DropDown.rcbCheckAllItemsCheckBox
    rcbCheckAllItemsCheckBox
    $telerik.$('.rcbCheckAllItemsCheckBox');
    also added
    src "jquery-ui.min.js" link
    as well as

    $(document).ready(function(){

    But to no avail

  6. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 07 Aug 2012 Link to this post

    Hi,

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

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script type="text/javascript">
    $("#RadComboBox1_DropDown .rcbCheckAllItemsCheckBox").click(function () {
                document.getElementById("HiddenField1").value = 1;
            });
    </script>

    Please have a look into this link.

    Thanks,
    Princy.
  7. RJ
    RJ avatar
    395 posts
    Member since:
    Oct 2006

    Posted 07 Aug 2012 Link to this post

    Seems like the problem on my end is that I'm using Masterpages. Will just have to find the correct prefix for the dropdown. Thanks a lot Princy.
  8. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 08 Aug 2012 Link to this post

    Hi RJ,

    Try modifying the Jquery selector as follows to acess the Checkall Item Checkbox.

    Javascript:
    <script type="text/javascript">
    $(".rcbCheckAllItemsCheckBox").click(function () {
                ............
            });
    </script>

    Hope this helps.

    Thanks,
    Princy.
  9. RJ
    RJ avatar
    395 posts
    Member since:
    Oct 2006

    Posted 08 Aug 2012 Link to this post

    It works but for all of the dropdown. I have 2 dropdown that only needs this for the postback. Anyway I was able to find the correct prefix.
    $("#[id$=BodyContentPlaceHolder_Radcombobox1] .rcbCheckAllItemsCheckBox").click(function () {

    Thanks again,
    RJ
Back to Top