Set comboboxItem invisible Client Side.

7 posts, 0 answers
  1. Fernandes
    Fernandes avatar
    33 posts
    Member since:
    Mar 2005

    Posted 13 Mar 2008 Link to this post

    Hi everyone,

    Client Side, is there a way to set a comboboxItem invisible?

    I've tried something like:

    var ddlPrecoMax = $find("<%= ddlPrecoMax.ClientID %>");  

    var

    maxLength= ddlPrecoMax.get_items().get_count();

    for(i=0; i< maxLength; i++)

    {

        var comboItem= ddlPrecoMax.get_items().getItem(i);  
        comboItem.set_visible(false);  
    }

    ... but it's not working.

    Can someone point me the correct way?

    Thanks in advance!
  2. Nikolay
    Admin
    Nikolay avatar
    3997 posts

    Posted 13 Mar 2008 Link to this post

    Hello Fernandes,

    Actually, the set_visible method of the RadComboBoxItems has not been fully implemented. Therefore, it is not working at the moment.  Is it acceptable for you to use the disable() method instead till we fully implement the set_visible() method in the official Q1 release due in April?

    Regards,
    Nick
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Trimox
    Trimox avatar
    20 posts
    Member since:
    Jul 2007

    Posted 13 Mar 2008 Link to this post

    Might help..

    if you just want one item disabled..
    var combo = $find("<%= ddlPrecoMax.ClientID %>");

    combo.findItemByText("Apples").disable();
    or if you want the entire combo disabled
    function DisableComboBox() {

      var combo = $find("<%=ddlPrecoMax.ClientID %>");

      combo.disable();

    }


  4. Fernandes
    Fernandes avatar
    33 posts
    Member since:
    Mar 2005

    Posted 13 Mar 2008 Link to this post

    Thanks both of you, but what I was looking for was really a way to set them invisible.

    I had to go through a different approach.


    Thanks anyway!

    Fernandes
  5. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 13 Mar 2008 Link to this post

    Hi Fernandes,

    Since you want to loop through all items and set their visibility to false, I would suggest using the clearItems()
    method of the ComboBox.


    Sincerely yours,
    Veskoni
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. Fernandes
    Fernandes avatar
    33 posts
    Member since:
    Mar 2005

    Posted 13 Mar 2008 Link to this post

    HI Veskoni,

    I was looping the items collection and I was trying to set invisible some of the items. (depending of its value). I just didn't put that on the first post, for simplicity.

    Thanks anyway!

    Fernandes



  7. The Wire
    The Wire avatar
    21 posts
    Member since:
    Jan 2010

    Posted 15 Jun 2010 Link to this post

    I'm having the same issue, but it's 2 years later now so the current version should include the full implementation of set_visible() for the RadComboBoxItem.  I'm using 2010.1.519.35.

    I've duplicated the Related ComboBox example (http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/multiplecomboboxes/defaultcs.aspx) and added this to my ItemsLoaded function:

    function ItemsLoaded(combo, eventArqs)  
    {      
        if (combo.get_items().get_count() > 0)  
        {  
            var sep = combo.findItemByText("Separator");  
            for (var i = 1; i < sep.get_index(); i++) {  
                var item = combo.get_items().getItem(i);  
                if (item.get_value().substr(0,2) != "53") {  
                    item.set_visible(false);  
                    //item.set_text("**" + item.get_text());  
                }  
            }  
        }  
        combo.showDropDown();  
    }  
     
    My combobox is divided into two sections which is why my loop only goes until it reaches the second section.  I want to hide items in the first section that don't start with a user's id, which I hard-coded a 53 in for testing.  I want to hide them rather than remove them so the user has the option to later show all items if they would need to select a different user's id.  However, the items are not hiding.  I've tried the .set_visible(false) and .hide(), neither are working for me.  If I uncomment the .set_text() line, all the items get "**" added to their text except those starting with "53", so I know I have reference to each item.  I have also tried removing the item too but that doesn't work either:
    function ItemsLoaded(combo, eventArqs)     
    {         
        if (combo.get_items().get_count() > 0)     
        {     
            var sep = combo.findItemByText("Separator");     
            for (var i = 1; i < sep.get_index(); i++) {     
                var item = combo.get_items().getItem(i);     
                if (item.get_value().substr(0,2) != "53") {  
                    combo.trackChanges();  
                    combo.get_items().remove(item);  
                    combo.commitChanges();  
                    //item.set_visible(false);     
                    //item.set_text("**" + item.get_text());     
                }     
            }     
        }     
        combo.showDropDown();     
    }   
     

    Couple other things to note: my RadComboBox is inside a GridTemplateColumn in a RadGrid.  I'm also using a masterpage within the context of SharePoint so all my controls are in a asp:Content placeholder.
Back to Top