Hi,
Default behavior when transferring items between ListBoxes seem to be that the adjacent item to the moved item in the source listbox is selected. This is not what I wanted, so I tried various ways to unselect all in the source listbox after a transfer.
When transferring items between two listboxes (AllowTransfer="true"), the ListBox.clearSelection dows not work on the source ListBox.
I also tried using this statement from another related thread:
Only way I made it work is the rather graceless way of using
Default behavior when transferring items between ListBoxes seem to be that the adjacent item to the moved item in the source listbox is selected. This is not what I wanted, so I tried various ways to unselect all in the source listbox after a transfer.
When transferring items between two listboxes (AllowTransfer="true"), the ListBox.clearSelection dows not work on the source ListBox.
I also tried using this statement from another related thread:
$telerik.$(sourceListBox._getGroupElement()).focus();
but this does not help.Only way I made it work is the rather graceless way of using
OnClientSelectedIndexChanged
as shown in this code:<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TestListBox.aspx.cs" Inherits="TestListBox" %> |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
<html xmlns="http://www.w3.org/1999/xhtml"> |
<head runat="server"> |
<title></title> |
<telerik:RadStyleSheetManager id="RadStyleSheetManager1" runat="server" /> |
</head> |
<body> |
<form id="form1" runat="server"> |
<telerik:RadScriptManager ID="RadScriptManager1" runat="server"> |
<Scripts> |
<%--Needed for JavaScript IntelliSense in VS2010--%> |
<%--For VS2008 replace RadScriptManager with ScriptManager--%> |
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" /> |
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" /> |
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" /> |
</Scripts> |
</telerik:RadScriptManager> |
<script type="text/javascript"> |
var lastSrcLB = ""; |
// Maintain edits in |
function ListBoxItemTransferred(sender, event) { |
var destinationListBox = event.get_destinationListBox(); |
var sourceListBox = event.get_sourceListBox(); |
//$telerik.$(destinationListBox._getGroupElement()).focus(); |
destinationListBox.clearSelection(); |
lastSrcLB = sourceListBox.get_id(); |
//$telerik.$(sourceListBox._getGroupElement()).focus(); |
sourceListBox.clearSelection(); |
} |
function SelectedIndexChanged(sender, e) { |
var item = e.get_item(); |
alert(sender.get_id() + "::" + lastSrcLB + "::" + item.get_text()); |
if (sender.get_id() == lastSrcLB) { |
lastSrcLB = ""; |
event.returnValue = false; // To late |
event.cancelBubble = true; |
item.set_selected(false); |
return false; |
} |
} |
</script> |
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> |
</telerik:RadAjaxManager> |
<div> |
<telerik:RadListBox ID="SystemUserListBox1" |
runat="server" |
OnClientTransferred="ListBoxItemTransferred" |
OnClientSelectedIndexChanged="SelectedIndexChanged" |
AllowTransfer="True" |
TransferToID="TeamUserListBox" |
> |
<ButtonSettings Position="Bottom" HorizontalAlign="Center" /> |
<Items> |
<telerik:RadListBoxItem runat="server" Text="RadListBoxItem1" /> |
<telerik:RadListBoxItem runat="server" Text="RadListBoxItem2" /> |
<telerik:RadListBoxItem runat="server" Text="RadListBoxItem3" /> |
<telerik:RadListBoxItem runat="server" Text="RadListBoxItem4" /> |
</Items> |
</telerik:RadListBox> |
<telerik:RadListBox ID="TeamUserListBox" |
runat="server" |
OnClientTransferred="ListBoxItemTransferred" |
OnClientSelectedIndexChanged="SelectedIndexChanged" |
> |
</telerik:RadListBox> |
</div> |
</form> |
</body> |
</html> |
Any better alternatives? (Would be nice if this behaviour could be set though properties..) Best Regards Gunnar Skogen |