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

Creating Undo Button for RadListBox

1 Answer 81 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Caleb
Top achievements
Rank 1
Caleb asked on 23 Apr 2012, 05:24 PM
I was told to add an undo button for the RadListBox that will track and then revert he changes a user makes. I have the code set up but I am getting undefined errors in dynmiac code when it is running through transferItem(). I am not entirely sure whats going wrong with it. If someone could look and give some advice that would be great.

var UndoList = new Array();
function onClientTransferring(sender, e) {
    var items = e.get_items();
    for (var i = 0; i < items.length; i++) {
        var item = items[i];
        if (item.get_text() != "Select" || item.get_value() != "") {
            UndoList.push(item);
            UndoList.push(e.get_sourceListBox());
            UndoList.push(e.get_destinationListBox());
        }
    }
}
function undoChanges() {
    if (UndoList[UndoList.length - 1]._clientStateFieldID == "rlbStations_ClientState") {
    var listbox = $find('rlbStations');
    }
else if (UndoList[UndoList.length - 1]._clientStateFieldID == "rlbAllowedStations_ClientState") {
    var listbox = $find('rlbAllowedStations');
    }
    listbox.transferItem(UndoList[UndoList.length - 3], UndoList[UndoList.length - 1], UndoList[UndoList.length - 2]);
}
<telerik:RadListBox ID="rlbStations" runat="server" AllowTransfer="True" TransferToID="rlbAllowedStations" Height="200px" Skin="Web20" SelectionMode="Multiple" Sort="Ascending" DataKeyField="station_id"
 AutoPostBackOnTransfer="true" Width="250px" OnClientTransferring="onClientTransferring"
OnTransferred="rlbStations_Transferred"><ButtonSettings ShowDelete="False" ShowReorder="False" /> </telerik:RadListBox>
<asp:Button Text="Undo" runat="server" OnClientClick="undoChanges()" /><telerik:RadListBox ID="rlbAllowedStations" runat="server" Height="200px" Width="250px" Skin="Web20"> </telerik:RadListBox>

1 Answer, 1 is accepted

Sort by
0
Dimitar Terziev
Telerik team
answered on 27 Apr 2012, 11:50 AM
Hi Caleb,

Could you please open a support ticket and provide a runnable sample so we could test it locally?

All the best,
Dimitar Terziev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
ListBox
Asked by
Caleb
Top achievements
Rank 1
Answers by
Dimitar Terziev
Telerik team
Share this question
or