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

Get all items of RadListBox

2 Answers 591 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Abhi Shinde
Top achievements
Rank 1
Abhi Shinde asked on 25 Jan 2012, 07:55 AM
Hi,,
I am using RadListBox, I want to get all values of listbox.
I am tying to use "get_items" method But it is showing foll. error.
Uncaught TypeError: Object [object Object] has no method 'get_items' 
 
ASPX code
<script type="text/javascript" charset="utf-8">
        $(document).ready(function() {
 
 $('#<%=btnViewAssignedSlots.ClientID %>').click(function() {
               var list = $('#<%= rdLstSource.ClientID %>');
                var items = list.get_items();
               var firstItem = items.getItem(0);
                alert(firstItem);
}
 
});
    </script>

<telerik:RadListBox runat="server" ID="rdLstSource" Height="200px" Width="230px"
                        AutoPostBackOnTransfer="false" AllowTransfer="true" TransferToID="rdLstDestination"
                        AllowTransferOnDoubleClick="true" EnableDragAndDrop="true" ButtonSettings-ShowTransferAll="true">
                        <Items>
                            <telerik:RadListBoxItem Text="Sunday" Value="1" />
                            <telerik:RadListBoxItem Text="Monday" Value="2"/>
                            <telerik:RadListBoxItem Text="Tuesday" Value="3"/>
                            <telerik:RadListBoxItem Text="Wednesday" Value="4"/>
                            <telerik:RadListBoxItem Text="Thursday" Value="5"/>
                            <telerik:RadListBoxItem Text="Friday" Value="6"/>
                            <telerik:RadListBoxItem Text="Saturday" Value="7"/>
                        </Items>
                    </telerik:RadListBox>

Please help me to solve.

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 25 Jan 2012, 10:03 AM
Hello,

Try the following javascript.
JS:
<script type="text/javascript">
    function OnClientClick()
     {
        var list = $find("<%=RadListBox1.ClientID %>");
        for (i = 0; i < list.get_items().get_count(); i++)
        {
          alert(list.getItem(i).get_value());
        }
    }
    </script>

Thanks,
Princy.
0
Accepted
Bozhidar
Telerik team
answered on 25 Jan 2012, 12:46 PM
Hi Abhi,

Please review the following help article, showing how to work with the RadListBox client object:
http://www.telerik.com/help/aspnet-ajax/listbox-client-side-basics.html 
 
All the best,
Bozhidar
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
Tags
ListBox
Asked by
Abhi Shinde
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Bozhidar
Telerik team
Share this question
or