Selected Items, Client

4 posts, 0 answers
  1. LEVEFAUDE
    LEVEFAUDE avatar
    39 posts
    Member since:
    Apr 2011

    Posted 23 Jan 2013 Link to this post

    Hello

    Can you tell me you to loop on selectedItems

     var listbox = $find("<%= lbEssenceDispo.ClientID %>");
     var items = listbox.get_selectedItems();

    I've not found how to do

    Thank a lot

    Anne
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 23 Jan 2013 Link to this post

    Hi,

    Try the following code snippet to achieve your scenario.

    JS:
    <script type="text/javascript">
        function OnClientClick() {
            var listbox = $find("<%= lbEssenceDispo.ClientID %>");
            var items = listbox.get_selectedItems();
            for (var i = 0; i < items.length; i++) {
                //get the selected items here
                var selecteditem = items[i];
            }
        }
    </script>

    Hope this helps.

    Regards,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. LEVEFAUDE
    LEVEFAUDE avatar
    39 posts
    Member since:
    Apr 2011

    Posted 24 Jan 2013 Link to this post

    Hi Princy and thank you !

    I've try this but "items.length" allways return 0
    Another idea ?

    Have a good day

    Anne
  5. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 24 Jan 2013 Link to this post

    Hi,

    I was not able the replicate the issue that you are facing. Following is the complete code which worked as expected at my end.

    ASPX:
    <telerik:RadListBox ID="lbEssenceDispo" runat="server" SelectionMode="Multiple">
        <Items>
            <telerik:RadListBoxItem Text="RadListBoxItem1" />
            <telerik:RadListBoxItem Text="RadListBoxItem2" />
            <telerik:RadListBoxItem Text="RadListBoxItem3" />
            <telerik:RadListBoxItem Text="RadListBoxItem4" />
            <telerik:RadListBoxItem Text="RadListBoxItem5" />
            <telerik:RadListBoxItem Text="RadListBoxItem6" />
            <telerik:RadListBoxItem Text="RadListBoxItem7" />
            <telerik:RadListBoxItem Text="RadListBoxItem8" />
            <telerik:RadListBoxItem Text="RadListBoxItem9" />
        </Items>
    </telerik:RadListBox>
    <asp:Button ID="Button1" runat="server" OnClientClick="OnClientClick(); return false;" />

    JS:
    <script type="text/javascript">
        function OnClientClick() {
            var listbox = $find("<%= lbEssenceDispo.ClientID %>");
            var items = listbox.get_selectedItems();
            for (var i = 0; i < items.length; i++) {
                //get the selected items here
                var selecteditem = items[i];
                alert(selecteditem.get_text());
            }
        }
    </script>

    Please provide your entire code if it doesn't help.

    Regards,
    Princy.
Back to Top