set index from java script

4 posts, 0 answers
  1. Dominik
    Dominik avatar
    11 posts
    Member since:
    Oct 2011

    Posted 27 Apr 2012 Link to this post

    Hello, I try from client side (java script) set index for RadListBox.

    How can I use document.getElementById for finding and set index for RadListBox ?

    regards,
    Dominik Kolcio
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 27 Apr 2012 Link to this post

    Hi Dominik,

    You can access the RadListBox using $find method and get the index as shown below.

    JS:
    <script type="text/javascript">
        function pageLoad()
        {
            var list = $find("<%= RadListBox1.ClientID %>");
            var items = list.get_items();
            list.trackChanges();
            var item = new Telerik.Web.UI.RadListBoxItem();
            item.set_text("New");
            item.set_value("Value");
            items.add(item);
            list.commitChanges();
            alert(item.get_index());
        }
    </script>

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Dominik
    Dominik avatar
    11 posts
    Member since:
    Oct 2011

    Posted 27 Apr 2012 Link to this post

    Yes, I try this before.
    When try to run app:
    The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

    But this problem I solved with RadScriptBlock.

    but I still can't set index in RadListBox from java script :(
    I don't need add any Items, because my RadListtBox is populated with data.

    I need select item by index.
  5. Dominik
    Dominik avatar
    11 posts
    Member since:
    Oct 2011

    Posted 27 Apr 2012 Link to this post

    I solved the problem.

    With clearSelection
    getItem and select

    thank you Shinu

    Dominik
Back to Top