Need to check checkbox item from outside the control

3 posts, 0 answers
  1. Albert
    Albert avatar
    2 posts
    Member since:
    Nov 2012

    Posted 17 Jan 2013 Link to this post

    I have a Gridview that uses a RadComboBox with checkboxes enabled to choose an Approval code or multiple denial codes. 

    I have a asp:checkbox in the grid up in the header as well as next to each RadComboBox control as an 'Approve All' function. It should work similar to the checkboxes in Gmail.
    You asp:checkbox in the header, which should check each asp:checkbox next to the RadComboBox controls in each row, will also set each RadComboBox to have the Approve item checked for selection.
    When you uncheck a asp:checkbox next to the RadComboBox, you only uncheck that RadComboBox, not all controls in all rows.

    I was wanting to do this all client side but can't see the get the checkboxes in the RadComboBox to check or uncheck. Also, I don't know if they are checked clientside if they will be picked up serverside when I'm ready to submit the approvals.

    The code is something like what follows:
    UPDATED THE CODE - When I had typed this out, I was writing it from memory. I have now posted the code as I am using it. The alerts do come up when I check or uncheck the checkbox next to the RadComboBox.

    $(checkBoxSelector).live('click', function () {
                    var index = $(checkBoxSelector).index(this);
                    var gridRow = $('#MainContent_QueueGrid > tbody > tr:eq(' + index + ')');
                    if ($(this).is(":checked")) {
                        gridRow.find('.rcbCheckBox').each(function () {
                            if ($(this)[0].nextSibling.wholeText === 'Approve') {
                                $(this)[0].attr("checked", true);
                                alert("Checking the box");
                    else {
                        gridRow.find('.rcbCheckBox').each(function () {
                            if ($(this)[0].nextSibling.wholeText === 'Approve') {
                                $(this)[0].attr("checked", false);
                                alert("UNChecking the box");

    I have tried every which way to check or uncheck the Approval code inside the RadComboBox and it is not working.
    I can see the Approval checkbox element when I get to the if statement but am not able to set the attribute to checked.
    I have tried attr('checked', true) along with every other way I can find.

    I know that if the asp:checkboxes are selected I could evaluate the grid with those, but my issue is for user experience. If the Approve All is selected, all of the RadComboBoxes should show Approved as the selcted text as well as if they open the RadComboBox, they should we Approved checked and possibly all denial codes disabled.

    Is this something that can be done?
    With your help, if I am successful in setting it, will the checked status hold when evaluating the grid in code behind?

    Any help is greatly appreciated.
    Thanks in advance.

  2. MasterChiefMasterChef
    MasterChiefMasterChef avatar
    152 posts
    Member since:
    Jan 2013

    Posted 18 Jan 2013 Link to this post

    { deleted }
  3. DevCraft R3 2016 release webinar banner
  4. Angel Petrov
    Angel Petrov avatar
    1002 posts

    Posted 22 Jan 2013 Link to this post

    Hi Albert,

    You can attach an event handler which according to the check box state checks the item in the RadComboBox. This is demonstrated in the code snippet below:

    $telerik.$('#CheckBox1').change(function () {
                        var checkedState = $telerik.$('#CheckBox1').attr("checked");
                        var combo = $find("<%= RadComboBox1.ClientID %>");
                        var currentItem = combo.findItemByText("Approve");
                        if (checkedState) {
                        else {

    In attachments you can find a sample solution demonstrating the upper-mentioned approach. Note that the changes made client-side are persisted server-side.

    All the best,
    Angel Petrov
    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