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

Change count of selected items

1 Answer 215 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Sebastian
Top achievements
Rank 1
Sebastian asked on 06 Apr 2018, 09:24 AM

Hi,

I have a RadComboBox which has an extra "Select All"-type item to select a sub set of all items. When this item is checked and the combobox is closed, I would like for the counter to ignore it when displaying how many items are checked.

e.g. The combobox contains "Select all", "Select all fruits", "apple", "banana", "monkey"

If I check "banana" and "monkey", it displays "2 items checked".

If I check "select all fruits", "apple" and "banana" will be checked but since "select all fruits" is also an item, it will display "3 items checked"

 

I haven't been able to find a way to have the combobox ignore one of the listitems or to change the count of selected items. Is this possible?

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 10 Apr 2018, 10:22 AM
Hello Sebastian,

You can achieve this requirement using the following approach:
<telerik:RadComboBox ID="RadComboBox1" runat="server" EmptyMessage="Select options"
    CheckBoxes="true" EnableCheckAllItemsCheckBox="true" Width="200px"
    OnClientItemChecked="itemChecked">
    <Items>
        <telerik:RadComboBoxItem Text="Select all fruits" Value="Fruits" BackColor="SkyBlue" />
        <telerik:RadComboBoxItem Text="Apple" Value="Apple" />
        <telerik:RadComboBoxItem Text="Banana" Value="Banana" />
        <telerik:RadComboBoxItem Text="Lemon" Value="Peach" />
        <telerik:RadComboBoxItem Text="Select all vegetables" Value="Vegetables" BackColor="SkyBlue" />
        <telerik:RadComboBoxItem Text="Onion" Value="Onion" />
        <telerik:RadComboBoxItem Text="Potato" Value="Potato" />
        <telerik:RadComboBoxItem Text="Select all animals" Value="Animals" BackColor="SkyBlue" />
        <telerik:RadComboBoxItem Text="Monkey" Value="Monkey" />
        <telerik:RadComboBoxItem Text="Cat" Value="Cat" />
        <telerik:RadComboBoxItem Text="Dog" Value="Dog" />
        <telerik:RadComboBoxItem Text="Bird" Value="Bird" />
    </Items>
</telerik:RadComboBox>
JavaScript:
function itemChecked(sender, args) {
    if (sender.get_text().indexOf("items checked") > 0) {
        sender.set_text("Multiple items checked");
    }
}

I hope this will prove helpful.

Regards,
Eyup
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
ComboBox
Asked by
Sebastian
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or