2012-04-20 4 views
0

Ok私は、私が考えていることが可能かどうかを知りたいだけです。私は研究を試みたが何も見つけることができなかった。私は2つのRadLsitBoxを持っていて、データを転送することができます。最後の転送を元に戻すことができる[元に戻す]ボタンを追加できるかどうかを知りたい。Telerik RadListBox、コードを使用してアイテムを転送

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> 

EDIT:

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]); 
    } 

答えて

3

JavaScriptを追加します。答えは:はい!組み込みの転送ボタンを使用せずにアイテムを転送することができます。ここでは例として、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"> 

http://www.telerik.com/help/aspnet-ajax/listbox-how-to-transfer-specific-items-with-transferall-button.html

+0

私はこのコードを試してみました、それは、転送ボタンで構築を使用して行います。 – cjohnson2136

+0

私は別のボタンのためにそれを使用しようとしましたが、それはそのコードにヒットしません。あなたがリンクした記事でさえ、デフォルトの転送ボタンを使用しないという言及はありません。 – cjohnson2136

+0

あなたは、別のボタンまたは選択したものからonClientTransferringを呼び出す必要があります。これは単なるコード例であり、最終的な解決策ではありません。 – msigman

関連する問題