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

OnClientItemChecked Not Fired

8 Answers 258 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
digitall
Top achievements
Rank 1
digitall asked on 23 Nov 2011, 08:19 PM
I am using the new Q3 2011 bits and noticed the OnClientItemChecked event doesn't fire when I have checkboxes enabled and click the "Check All" option. Selecting/Deselecting any option underneath fires the event, but "Check All" doesn't.

Any tips on how to make that happen?

8 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 24 Nov 2011, 05:30 AM
Hello,

Check the following forum thread which discussed similar scenario.
RadComboBox OnItemChecked not firing when checking All checkbox

-Shinu.
0
digitall
Top achievements
Rank 1
answered on 24 Nov 2011, 05:41 PM
I think that applies to the server-side event. I need to get it to fire client-side because I have to run a script whenever something changes, but the script doesn't run server-side.
0
Kalina
Telerik team
answered on 29 Nov 2011, 11:36 AM
Hello Digitall,

As I understand – you want to perform a custom client-side action when the "CheckAllItems" checkbox is checked. You can easily attach a change() event handler at this checkbox in this way:
<head runat="server">
<title></title>
<script type="text/javascript" language="javascript">
function onLoad(sender) {   
    $telerik.$('.rcbCheckAllItemsCheckBox').change(function() {          
   if(sender.get_text() == "All items checked")
   {
  alert(sender.get_text()+ " and you can perform some custom action here");
   }         
    });
}   
</script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <telerik:RadComboBox ID="RadComboBox1" runat="server"
            CheckBoxes="true"  OnClientLoad="onLoad"
            EnableCheckAllItemsCheckBox="true" >
            <Items>
                <telerik:RadComboBoxItem Text="item 1" Value="1" />
                <telerik:RadComboBoxItem Text="item 2" Value="2" />
                <telerik:RadComboBoxItem Text="item 3" Value="3" />
            </Items>
        </telerik:RadComboBox>
    </div>
    </form>
</body>

Greetings,
Kalina
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
0
digitall
Top achievements
Rank 1
answered on 29 Nov 2011, 05:39 PM
This doesn't seem to be working quite right. I have 8 total items in my list (pulled from a DB table, but essentially static) and when some of the items are checked and then the "Check All" option is selected it doesn't fire. I modified the function you posted here to do an alert whenever something is checked and it looks like the text of that item changes based on what is selected. For instance, using that example (7 items selected), when I hit the "Check All" option the alert shows "7 items checked" (which is just sender.get_text()). When nothing is selected and I hit the "Check All" option the alert pops up but the text is blank. This confirms my thought that the checkbox's get_text() value is equal to whatever number of items are selected (or "All items checked") if that's the case.

In my current scenario I can just call the function I'm trying to without caring which item is selected (i.e. no need to compare sender.get_text() to anything), but any ideas should that scenario change for me or someone else needs this functionality?
0
Kalina
Telerik team
answered on 30 Nov 2011, 04:28 PM
Hi Digitall,

The sample script that I provided you just demonstrates how to attach a "change" event (and handler function) at the CheckAllItems CheckBox element.
I am not sure what exactly your modification is, but when all items are checked - the text within RadComboBox input should be "All items checked" and when there are no checked items - the input should be empty.
Additionally we will consider implementing a new event to be fired when CheckAllItems CheckBox is checked in our future releases.

Regards,
Kalina
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
0
Rick
Top achievements
Rank 1
answered on 08 Jun 2012, 12:32 PM
I did something like the following:
<tr>
    <td bgcolor="#FFFFFF" class="grey33-13">
        Select Other  
            <telerik:RadComboBox ID="ddlAssignOther" runat="server" 
                 CheckBoxes="true"
                EnableCheckAllItemsCheckBox="true" AppendDataBoundItems="true" OnClientDropDownClosed="closed"
                EnableLoadOnDemand="true" EnableTextSelection="true" MarkFirstMatch="true">
            </telerik:RadComboBox
    </td>
    <td>
        <telerik:RadTextBox runat="server" ID="txtOthers" TextMode="MultiLine" ReadOnly="true" Height="40" Width="300"></telerik:RadTextBox>
    </td>
</tr>



function
closed(sender, eventArgs) {
    var combo = $find("<%= ddlAssignOther.ClientID %>");
    combo = combo.get_checkedItems()
    var txt = document.getElementById("<%=txtOthers.ClientID %>");
    if (sender._checkAllItemsElement[0].all[0].checked) {
        for (var i = 0; i < combo.length; i++) {
            if (i == 0) {
                txt.value = combo[0]._text;
            }
            else {
                text = txt.value;
                if (text.indexOf(combo[i]._text) == -1) {
                    txt.value = txt.value + ',' + combo[i]._text;
                }
            }
        }
    }
    else {
        if (combo.length > 0) {
            for (var i = 0; i < combo.length; i++) {
                if (combo[i]._checkBoxElement.checked) {
                    if (i == 0) {
                        txt.value = combo[0]._text;
                    }
                    else {
                        text = txt.value;
                        if (text.indexOf(combo[i]._text) == -1) {
                            txt.value = txt.value + ',' + combo[i]._text;
                        }
                    }
                }
            }
        }
        else { txt.value = ""; }
    }
}
0
Phil
Top achievements
Rank 1
answered on 13 Nov 2012, 12:12 PM
Kalina,

Sorry to resurrect an old thread but you mentioned implementing this feature: "Additionally we will consider implementing a new event to be fired when CheckAllItems CheckBox is checked in our future releases." Was this ever implemented? It is a feature that should really be there in my eyes. Your controls are good but sometimes they are just missing little things like this which is a little disappointing.

Thanks
Phil
0
Kalina
Telerik team
answered on 16 Nov 2012, 10:40 AM
Hello Phil,

Please accept our apologies for the inconvenience caused.
Indeed this feature is not implemented yet, but it is included in our plans for the next release.

Meanwhile I can suggest you handle the OnClientLoad event of the RadComboBox and attach a "change" event handler at the "CheckAll" checkbox:

<script type="text/javascript" language="javascript">
function onLoad(sender) {   
    $telerik.$('.rcbCheckAllItemsCheckBox').change(function() {          
     __doPostBack();                 
    });
}   
 
</script>

<telerik:RadComboBox ID="RadComboBox1" runat="server" EnableAriaSupport="true"
        OnItemChecked="RadComboBox1_ItemChecked" EnableOverlay="false"
    CheckBoxes="true"  OnClientLoad="onLoad"
    EnableCheckAllItemsCheckBox="true" >
    <Items>
        <telerik:RadComboBoxItem Text="item 1" Value="1" />
        <telerik:RadComboBoxItem Text="item 2" Value="2" />
        <telerik:RadComboBoxItem Text="item 3" Value="3" />
    </Items>
</telerik:RadComboBox>
<asp:Label ID="lblPostBack" runat="server"></asp:Label>

protected void Page_Load(object sender, EventArgs e)
{
    lblPostBack.Text = this.RadComboBox1.Text;
}



Regards,
Kalina
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
digitall
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
digitall
Top achievements
Rank 1
Kalina
Telerik team
Rick
Top achievements
Rank 1
Phil
Top achievements
Rank 1
Share this question
or