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

Remove element of a double click Radlistbox

2 Answers 176 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 09 May 2013, 07:18 PM
I was able to copy items from one radListBox to another but I could not delete them by double clicking on the item. thanks for your help

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 10 May 2013, 05:34 AM
Hi Andrew,

Please have a look at the following sample code I tried which works fine at my end.

ASPX:
<telerik:RadListBox ID="RadListBox1" runat="server" OnClientItemDoubleClicked="OnClientItemDoubleClicked"
    SelectionMode="Single">
    <Items>
        <telerik:RadListBoxItem runat="server" Text="Item1" />
        <telerik:RadListBoxItem runat="server" Text="Item2" />
        <telerik:RadListBoxItem runat="server" Text="Item3" />
        <telerik:RadListBoxItem runat="server" Text="Item4" />
    </Items>
</telerik:RadListBox>

JavaScript:
<script type="text/javascript">
    function OnClientItemDoubleClicked(sender, args) {
        listBox = $find("<%= RadListBox1.ClientID %>");
        var item = args.get_item();
        listBox.trackChanges();
        listBox.get_items().remove(item);
        listBox.commitChanges();
        return false;
    }
</script>

Thanks,
Shinu.
0
Andrew
Top achievements
Rank 1
answered on 10 May 2013, 02:38 PM
Thank you very much, it worked correctly
Tags
ListBox
Asked by
Andrew
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Andrew
Top achievements
Rank 1
Share this question
or