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

RadCombobox Check All on Initial Load

12 Answers 2357 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Ricky
Top achievements
Rank 1
Ricky asked on 24 Apr 2012, 12:31 PM
Hi,

I want check all my checkbox on RadCombobox when initial load.
Is there any feature to do that ?

Thanks,
Ricky

12 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 24 Apr 2012, 01:08 PM
Hi Ricky,

Try the following code to check all checkboxes in a RadComboBox in pageload.

C#:
protected void Page_Load(object sender, EventArgs e)
    {
   foreach (RadComboBoxItem itm in RadComboBox1.Items)
       {
       itm.Checked = true;
       }
    }

Thanks,
Princy.
0
Ricky
Top achievements
Rank 1
answered on 24 Apr 2012, 01:27 PM
Thanks for the quick response..i just thinking if there is another way around other than Princy gave.

Thanks a lot !!
0
AR
Top achievements
Rank 1
answered on 26 Dec 2012, 12:43 PM
Hi,

I have tried two ways of doing it :

ddlLanguage.ItemDataBound += MultiSelectDropDownItemBound;
 
private void MultiSelectDropDownItemBound(object sender, RadComboBoxItemEventArgs e)
{
    e.Item.Checked = true;
}
 
private void SelectAllItemsInDropDown(RadComboBox rcbDropDown)
{
    foreach (RadComboBoxItem rcbItem in rcbDropDown.Items)
        rcbItem.Checked = true;
}

In both ways when the page loads we will see all items checked in the dropdown. It also intelligently checks "All Items Checked" checkbox.

But am facing a problem on trying to unselect all by clicking "Check All". We have to click twice to get this working.

Is there any fix/workaround or a new property that we can set in the control itself like "AllItemsChecked = true" from server itself?
0
Helen
Telerik team
answered on 28 Dec 2012, 10:46 AM
Hello Ashik,

Regarding the "Check All" issue that you have to check it twice - I believe the problem is fixed in the latest version - 2012.3.1205.
Otherwise we haven't such a property about the "AllItemsChecked".

Regards,
Helen
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
Deekshith
Top achievements
Rank 1
answered on 01 Apr 2014, 01:23 PM
Hi,Bellow code contains RadComboBox with checkbox option,I need help to select all checkboxes when header check box is checked and uncheck header if child checkboxes are unchecked and Iam using Rad controlls for Ajax Q3 2010 version and it not supports checkbox property to select all at all. Please Suggest me some javascript to check all/Uncheack all checkboxes when header is checked.Thank You in advance.
<telerik:RadComboBox ID="RadComboBox1" Runat="server" OnClientDropDownClosed="onDropDownClosing" HighlightTemplatedItems="true"
                        AllowCustomText="true">
                        
                        <ItemTemplate>
                        <div onclick="StopPropagation(event)">
                            <asp:CheckBox runat="server" ID="chk1"/>
                                <asp:Label runat="server" ID="Label1" AssociatedControlID="chk1" Text='<%#DataBinder.Eval(Container.DataItem,"Names")%>'/>
                        </div>
                        </ItemTemplate>
                        
                        <HeaderTemplate>
                            <asp:CheckBox ID="chkHeader" runat="server" Text="All"/>
  
                        </HeaderTemplate>
                    </telerik:RadComboBox>
0
Princy
Top achievements
Rank 2
answered on 02 Apr 2014, 05:24 AM
Hi Deekshith,

Please try the following JavaScript code snippet which works as expected for me.

ASPX:
...          
<HeaderTemplate>
    <asp:CheckBox ID="chkHeader" runat="server" Text="All" onclick="Checked(this);" />
</HeaderTemplate>
...

JavaScript:
<script type="text/javascript">
    function Checked(checkbox) {
        var combobox = $find("<%=RadComboBox1.ClientID %>");
        if (checkbox.checked == true) {
            for (var i = 0; i < combobox.get_items().get_count(); i++) {
                $telerik.findElement(combobox.get_items()._array[i].get_element(), "chk1").checked = true;
            }
        }
        else if (checkbox.checked == false) {
            for (var i = 0; i < combobox.get_items().get_count(); i++) {
                $telerik.findElement(combobox.get_items()._array[i].get_element(), "chk1").checked = false;
            }
        }
    }
</script>

Thanks,
Princy.
0
Deekshith
Top achievements
Rank 1
answered on 02 Apr 2014, 06:31 AM
Thanks for your quick reply Princy.But I'am getting the following error:JavaScript runtime error: Unable to set property 'checked' of undefined or null reference
0
Deekshith
Top achievements
Rank 1
answered on 02 Apr 2014, 06:38 AM
Thank You Soo Much Princy..its working fine now.Actually i did some thing wrong in my code so i got that error.now its resolved. 
0
Deekshith
Top achievements
Rank 1
answered on 02 Apr 2014, 07:29 AM
Princy do you know how to uncheck the header when any one checkbox in item template unchecked??
0
Princy
Top achievements
Rank 2
answered on 03 Apr 2014, 03:12 AM
Hi Deekshith,

Please try the following code snippet which works fine at my end.

ASPX:
...
<ItemTemplate>
    <div>
        <asp:CheckBox runat="server" ID="chk1" onclick="UncheckHeader(this);" />
        ...
    </div>
</ItemTemplate>
...

JavaScript:
function UncheckHeader(checkbox) {
    var combobox = $find("<%=RadComboBox1.ClientID %>");
    if (checkbox.checked == false) {
        var checkbox = document.getElementById('<%=(RadComboBox1.Header.FindControl("chkHeader") as CheckBox).ClientID %>');
        checkbox.checked = false;
    }
}

Thanks,
Princy.
0
Deekshith
Top achievements
Rank 1
answered on 03 Apr 2014, 04:17 AM
Thank You Princy :)
0
Lucky
Top achievements
Rank 1
answered on 10 Nov 2017, 01:22 PM

I have telerik radcombobox and i have properties like CheckBoxes="true" ,EnableCheckAllItemsCheckBox="true" and "Contains".

if i search something it is showing related to search.i checked check all option for whatever i searched. after closing radcombox if u open again it is showing that whatever we have data that all data is showing like cheked.but i want whatever i searched that data only i want to show as checked after open the radcombobox.Below i attached 2 images in 1st image i checked only 4 items .but again if i open radcombobox it is ahowing that 5 items checked

Tags
ComboBox
Asked by
Ricky
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Ricky
Top achievements
Rank 1
AR
Top achievements
Rank 1
Helen
Telerik team
Deekshith
Top achievements
Rank 1
Lucky
Top achievements
Rank 1
Share this question
or