'How to clear rad listbox items from client side

I have a radlistbox i want clear the radlistbox items. i had tried this code but not working as expected.Can someone give me a idea how can i do this.

Thanks.

 <telerik:RadListBox RenderMode="Lightweight" runat="server" AllowReorder="True" AllowDelete="true" ID="RadListBox1" Height="200px" Width="230px" AutoPostBack="false" ButtonSettings-AreaWidth="35px">
      <ButtonSettings Position="Right" AreaWidth="35px"></ButtonSettings>
 </telerik:RadListBox>

Script:

function ClearListbox()
{
    var listBox = $find('<%=RadListBox1.ClientID%>');
    listBox.trackChanges();
    listBox.clearSelection();
    listBox.commitChanges();

}


Solution 1:[1]

The clearSelection method just removes the highlight from the selected item.

You should use the get_items().remove or removeAt methods to succeed:

var lb = $find("ctl00_ContentPlaceholder1_RadListBoxSource");
var item = lb.get_selectedItem();
lb.trackChanges();
lb.get_items().remove(item);
lb.commitChanges();

You will also need a selection to be able to remove the selected item.

Check out this article for more information https://docs.telerik.com/devtools/aspnet-ajax/controls/listbox/radlistbox-items/working-at-client-side#removing-items

Solution 2:[2]

If you're seeing this now and wondering how to clear 'ALL' items in the RadListBox using javascript. There's a clear method that's weirdly hard to find info on. Code below:

var lb = $find("<%= yourListNameHere.ClientID %>");
lb.trackChanges();
lb.get_items().clear();
lb.commitChanges();

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rumen Jekov
Solution 2 KJN