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

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

1 Answer 89 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Tracy
Top achievements
Rank 1
Tracy asked on 03 Mar 2015, 06:24 AM
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"

1 Answer, 1 is accepted

Sort by
0
Accepted
Bozhidar
Telerik team
answered on 03 Mar 2015, 09:29 AM
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.

 
Tags
DropDownList
Asked by
Tracy
Top achievements
Rank 1
Answers by
Bozhidar
Telerik team
Share this question
or