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

RadComboBoxItem javascript .hide() and Filter="Contains"

3 Answers 209 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 25 Jun 2010, 05:43 PM

 

 


I am trying to set conditional RadComboBoxItem visibility using javascript: RadComboBoxItem.hide().  It will work fine without Filter="Contains" enabled on the ComboBox, but when this is turned on, the ComboBox shows the hidden items the second time it is opened.  Is there any way around this.

Thanks,
Thomas

aspx:

 

<telerik:RadComboBox runat="server" ID="rcbTest" Filter="Contains" > 
    <Items> 
        <telerik:RadComboBoxItem Text="Test1" /> 
        <telerik:RadComboBoxItem Text="Test2" /> 
        <telerik:RadComboBoxItem Text="Test3" /> 
        <telerik:RadComboBoxItem Text="Test4" /> 
    </Items> 
</telerik:RadComboBox> 
<asp:CheckBox ID="cbxTest" runat="server" onclick="Test(this);" /> 

javascript:

 
    function Test(cbx) {  
        var rcb = $find('<%=rcbTest.ClientID %>');  
        var items = rcb.get_items();  
        for (var i = 0; i < items.get_count(); i++) {  
            if (i != 2) {  
                if(cbx.checked)  
                    items.getItem(i).hide();  
                else  
                    items.getItem(i).show();  
            }  
                  
        }  
    } 

 

3 Answers, 1 is accepted

Sort by
0
Thomas
Top achievements
Rank 1
answered on 25 Jun 2010, 06:04 PM
It looks like you have to expand and then click outside the ComboBox and then expand again.  Clicking the drop down arrow multiple times to show and hide does not cause the same behavior.

Thomas
0
Yana
Telerik team
answered on 01 Jul 2010, 12:21 PM
Hello Thomas,

Filter property of the combobox actually provides client-side filtering - it hides some of the items. That's why you cannot use it in your case where you hide items manually.

Greetings,
Yana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jesus
Top achievements
Rank 1
answered on 29 Apr 2011, 09:43 PM
Maybe if you try to disabled those hidden radcomboboxitem.

IE:
    function DisableItem()
    {      
       var combo = $find("<%= RadComboBox1.ClientID %>");
       var comboItem = combo.get_selectedItem();
       combo.trackChanges();
       comboItem.disable();
       combo.commitChanges();
    }
Tags
ComboBox
Asked by
Thomas
Top achievements
Rank 1
Answers by
Thomas
Top achievements
Rank 1
Yana
Telerik team
Jesus
Top achievements
Rank 1
Share this question
or