好的,我只是想知道我的想法是否可行。我尝试过研究,但却找不到任何东西。我有两个RadLsitBox,我可以在之间传输数据。我想知道是否可以添加一个可以撤消我上次转移的撤消按钮。
FYI客户想要一个撤销按钮。我不认为只有通过代码才能传递项目而不按下按钮,但是如果某人有办法,我希望听到。
<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" OnTransferred="rlbStations_Transferred">
<ButtonSettings ShowDelete="False" ShowReorder="False" />
</telerik:RadListBox>
<telerik:RadListBox ID="rlbAllowedStations" runat="server" Height="200px" Width="250px"
Skin="Web20">
</telerik:RadListBox>
编辑:添加javascript
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());
sender.transferItem(item, e.get_sourceListBox(),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 - 2], UndoList[UndoList.length - 1]);
}
答案 0 :(得分:3)
答案是:是的!您可以在不使用内置传输按钮的情况下传输项目。以下是使用JavaScript作为示例的代码示例:
function onClientTransferring(sender, e) {debugger
//cancel the event
e.set_cancel(true);
//manually transfer the appropriate items
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() != "") {
sender.transferItem(item, e.get_sourceListBox(), e.get_destinationListBox());
}
}
}
RadListBox
:
<telerik:RadListBox ID="RadListBox1"
runat="server"
Skin="Vista"
AllowTransfer="true"
TransferToID="RadListBox2"
DataKeyField="ID"
OnClientTransferring="onClientTransferring"
DataTextField="Name"
DataValueField="ID"
DataSourceID="SqlDataSource1" >
</telerik:RadListBox>
<telerik:RadListBox ID="RadListBox2" runat="server"
Skin="Vista"
AllowTransfer="true">