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

RadCombobox with checkboxes

3 Answers 73 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Mani PC
Top achievements
Rank 1
Mani PC asked on 30 Mar 2013, 11:40 PM
i have a combobox with checkboxes...

i need a javascript that will check/uncheck all items in the list....

here is my markup...

------------------------------------------------

 

<telerik:RadComboBox ID="cmbDeptDCVL" runat="server" AllowCustomText="false" HighlightTemplatedItems="True" Width="100"

 TabIndex="6" DropDownWidth="320px" >

 <HeaderTemplate>

 <table>

 <tr>

 <td width="20">

 <asp:CheckBox ID="chkAllDCVL" runat="server" ToolTip="Select/Deselect All" Text="" />

 </td>

 <td width="80"> Dept </td>

 <td width="220">Description </td>

 </tr>

 </table>

 </HeaderTemplate>

 <ItemTemplate>

 <table>

 <tr align="left">

 <td width="20">

 <asp:CheckBox runat="server" ID="chkSingleDCVL" Text="" />

 </td>

 <td width="80" align="left"> <%#CType(Container.DataItem, PhysicalInventory.Models.ApplCompStructInfo).DeptId%> </td>

 <td width="220" align="left"> <%#CType(Container.DataItem, PhysicalInventory.Models.ApplCompStructInfo).DeptShortDesc%> </td>

 </tr>

 </table>

 </ItemTemplate>

  

<CollapseAnimation Duration="200" Type="OutQuint" />

 </telerik:RadComboBox>

 -----------------

any help

Thanks

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 01 Apr 2013, 07:19 AM
Hi,

Please try the following JavaScript code.

JavaScript:
<script type="text/javascript">
    function pageLoad() {
        var combobox = $find('<%=cmbDeptDCVL.ClientID %>');
        var items = combobox.get_items();
        var itemCount = items.get_count()
        for (var counter = 0; counter < itemCount; counter++) {
            var item = items.getItem(counter);
            item.set_checked(true)
        }
    }
</script>

Thanks,
Princy.
0
Mani PC
Top achievements
Rank 1
answered on 01 Apr 2013, 12:04 PM
Thanks.

My combobox is placed inside RadPanelBar control.... Any idea?

 <telerik:RadPanelBar runat="server" ID="rpbReconciliationSummaryInquiry" Height="300"  

Font-Bold="True" Font-Size="Large" ExpandMode="SingleExpandedItem" OnClientItemExpand="OnClientItemExpand" 

Width="300" EnableViewState="False">

 <Items>  

<telerik:RadPanelItem Expanded="False" Text="Dept / Class / Vendor / Location" Value="DCVLTop" Font-Bold="True" ForeColor="White">

 <Items>  

<telerik:RadPanelItem Value="DCVL" Text=""> 

<ItemTemplate>  

<table> 

<tr>
<td> 

<asp:Label ID="lblDept" runat="server" Text="Dept:" CssClass="label" />

 </td> 

<td>
<telerik:RadComboBox ID="cmbDeptDCVL" runat="server" AllowCustomText="false" HighlightTemplatedItems="True" Width="100"

 TabIndex="6" DropDownWidth="320px">

 <HeaderTemplate>  

<table> 

<tr>  

<td width="20"> 

<asp:CheckBox ID="chkAllDeptDCVL" runat="server" ToolTip="Select/Deselect All" Text="" OnCheckedChanged="ToggleAllItemsDeptDCVL" AutoPostBack="True" /> 

</td> 

<td width="80"> Dept </td>  

<td width="220">Description </td> 

</tr>  

</table

</HeaderTemplate>  

<ItemTemplate> 

<table> 

<tr align="left"> 

<td width="20">  

<asp:CheckBox runat="server" ID="chkSingleDeptDCVL" Text="" OnCheckedChanged="ToggleSelectedItemsDeptDCVL" AutoPostBack="True" />

 </td>  

<td width="80" align="left"> <%#Eval("DeptId")%></td> 

<td width="220" align="left"> <%#Eval("DeptShortDesc")%></td>  

</tr> 

</table>  

</ItemTemplate> 

<CollapseAnimation Duration="200" Type="OutQuint" />  

</telerik:RadComboBox> 

</td>  

</tr>

 

0
Hristo Valyavicharski
Telerik team
answered on 03 Apr 2013, 03:51 PM
Hi Mani,

When RadComboBox is nested inside other container $find('<%=cmbDeptDCVL.ClientID %>') will throw a compile time error in VS. Use Telerik.Web.UI.RadComboBox.ComboBoxes[0] instead. Telerik.Web.UI.RadComboBox.ComboBoxes returns collection of all combos on the page and you can get the one you need. Then the Princy's code will be as follows:
function pageLoad() {
    //Get the first combo
    var combobox = Telerik.Web.UI.RadComboBox.ComboBoxes[0];
    var items = combobox.get_items();
    var itemCount = items.get_count()
    for (var counter = 0; counter < itemCount; counter++) {
        var item = items.getItem(counter);
        item.set_checked(true)
    }
}


Regards,
Hristo Valyavicharski
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
Mani PC
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Mani PC
Top achievements
Rank 1
Hristo Valyavicharski
Telerik team
Share this question
or