Can not remove the item which is not selected on client side.

2 posts, 1 answers
  1. Tracy
    Tracy avatar
    8 posts
    Member since:
    Mar 2013

    Posted 03 Mar 2015 Link to this post

    for example:
    <!DOCTYPE html">
    <head runat="server">
    <script type="text/javascript">
    function pageLoad()
    {
        $find("DropDownList").get_items().removeAt(0);
    }
    </script>
    </head>
    <body>
    <form runat="server">
    <Telerik:RadScriptManager runat=server />
    <Telerik:RadDropDownList runat=server ID=DropDownList>
        <Items>
            <Telerik:DropDownListItem Text=1 />
            <Telerik:DropDownListItem Text=2 Selected />
            <Telerik:DropDownListItem Text=3 />
        </Items>
    </Telerik:RadDropDownList>
    </form>
    </body>
    </html>
    Open the page above, then select the item "3", It will cause that the item "2" will not able to select.
    The Version of my RadControl is "2014 Q1"
  2. Answer
    Bozhidar
    Admin
    Bozhidar avatar
    1101 posts

    Posted 03 Mar 2015 Link to this post

    Hi,

    I confirm that this is a bug in the DropDownList control, which we will address as soon as we can. In the meantime you can use the following workaround:
    function pageLoad() {
        var dropDownList = $find("DropDownList")
        var selectedIndex = dropDownList._selectedIndex;
        var indexToRemove = 0;
     
        dropDownList.get_items().removeAt(0);
     
        if (selectedIndex > indexToRemove) {
            dropDownList._selectedIndex = selectedIndex - 1;
        }
    }


    Regards,
    Bozhidar
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top