Get all ComboBox Items (visible and not visible) in client-side

5 posts, 0 answers
  1. Fatima
    Fatima avatar
    18 posts
    Member since:
    Aug 2012

    Posted 19 Sep 2012 Link to this post

    Hi

    I use a RadComboBox with checkboxe that I hanle its event with javasript.

    In server-side we need to set visibility of its items based on user search, then with javascript process them.

    combo.get_items()   ::   in client-side return only those Items that are visible.

    what should I do for it?

    thanks.

  2. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 20 Sep 2012 Link to this post

    Hello Fatima,

    You can try hiding a RadComboBoxItem by setting its Visible property to false.
    Such item will not be included in RadComboBox items collection at client-side.
    <script type="text/javascript">
        function OnClientLoad(sender) {
     
            var itemsTexts="RadComboBox items are: ";
            var items = sender.get_items();
            for (i = 0; i < items.get_count(); i++)
            {
                itemsTexts += items.getItem(i).get_text() + ", ";
            }
            alert(itemsTexts);
        }
    </script>
     
    <telerik:RadComboBox ID="RadComboBox2" runat="server"
    CheckBoxes="true" EnableCheckAllItemsCheckBox="true"  
    OnClientLoad="OnClientLoad"
    AutoPostBack="true">
        <Items>
            <telerik:RadComboBoxItem Text="Arts" />
            <telerik:RadComboBoxItem Text="Biographies" />
            <telerik:RadComboBoxItem Text="Children's Books" />
            <telerik:RadComboBoxItem Text="Computers" />
      
        </Items>
    </telerik:RadComboBox>

    All the best,
    Kalina
    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.
  3. Fatima
    Fatima avatar
    18 posts
    Member since:
    Aug 2012

    Posted 21 Sep 2012 Link to this post

    Hi Kalina KalinaThanks for your response, but you exactly repeated my problem.

    You know it, but what 's its solution?
  4. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 24 Sep 2012 Link to this post

    Hi Fatima,

    When setting the Visible property to "false", the item is not rendered on page, and you will not able to access it from client side 
    One suggestion is that you can set the style display to false as follows.

    C#:
    RadComboBox1.Items.FirstOrDefault().CssClass = "hidden";

    CSS:
    <style type="text/css">
     .hidden
     {
       display:none !important;
     }
    </style>

    Thanks,
    Princy.
  5. Fatima
    Fatima avatar
    18 posts
    Member since:
    Aug 2012

    Posted 26 Sep 2012 Link to this post

    Many thanks
Back to Top