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

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

4 Answers 316 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Fatima
Top achievements
Rank 1
Fatima asked on 19 Sep 2012, 07:43 AM
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.

4 Answers, 1 is accepted

Sort by
0
Kalina
Telerik team
answered on 20 Sep 2012, 04:38 PM
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.
0
Fatima
Top achievements
Rank 1
answered on 21 Sep 2012, 06:43 PM
Hi Kalina KalinaThanks for your response, but you exactly repeated my problem.

You know it, but what 's its solution?
0
Princy
Top achievements
Rank 2
answered on 24 Sep 2012, 09:20 AM
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.
0
Fatima
Top achievements
Rank 1
answered on 26 Sep 2012, 11:29 AM
Many thanks
Tags
ComboBox
Asked by
Fatima
Top achievements
Rank 1
Answers by
Kalina
Telerik team
Fatima
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or