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

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

8 Answers 309 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
RJ
Top achievements
Rank 1
RJ asked on 02 Aug 2012, 09:32 PM
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

8 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 03 Aug 2012, 05:32 AM
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.
0
RJ
Top achievements
Rank 1
answered on 03 Aug 2012, 01:26 PM
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
0
Princy
Top achievements
Rank 2
answered on 06 Aug 2012, 05:13 AM
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.
0
RJ
Top achievements
Rank 1
answered on 07 Aug 2012, 11:11 AM
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

0
Accepted
Princy
Top achievements
Rank 2
answered on 07 Aug 2012, 11:45 AM
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.
0
RJ
Top achievements
Rank 1
answered on 07 Aug 2012, 03:46 PM
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.
0
Princy
Top achievements
Rank 2
answered on 08 Aug 2012, 08:12 AM
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.
0
RJ
Top achievements
Rank 1
answered on 08 Aug 2012, 01:38 PM
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
Tags
ComboBox
Asked by
RJ
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
RJ
Top achievements
Rank 1
Share this question
or