This is an fyi post for anyone one who might be have a simular problem. I plan on submitting a problem ticket as well.
I have a project which requires two listboxes (transfer back and forth). The "select from listbox" contains a list of Clients (with each client having a corresponding time zone. One of the requirements is have a dropdown containing time zones just below the "select from listbox". When you select a timezone from the dropdown, the Listbox should select all Clients with matching timezones (so you can easily transfer all clients for that time zone).
No real problem so far, I simply added the RadListBoxItems to the Listbox one at a time looping through the datatable setting the time zone of the client to the tooltip of the RadListBoxItem. With some javascript I snagged from the forums here I was able to loop through the listbox and compare the tooltip with the dropdown selected value, selecting the item if it matches.
Instead of turning on AutoPostBackOnTransfer, I added a button "Sort Lists" that can be clicked if the user feels the need to sort the lists.
Here's where the problem occurs, it seems as though any RadListBoxItem that is moved during the SortItems process looses it's tooltip (if an item isn't moved the tooltip will reamin).
I was able to work around this problem by adding an attribute to the RadListBoxItem (it seems attributes do persist after a sort) and then looping through the ListBox after SortItems and reassigning the Tooltip.
markup :
<
table
><
tr
>
<
td
valign
=
"top"
>
<
asp:Label
ID
=
"lblPracticeSelect"
runat
=
"server"
Text
=
"Practice Select:"
></
asp:Label
><
br
/>
<
telerik:RadListBox
ID
=
"rlbPracticeSelect"
runat
=
"server"
Height
=
"257px"
Width
=
"225px"
AllowTransfer
=
"True"
AllowTransferOnDoubleClick
=
"True"
EnableDragAndDrop
=
"True"
EnableMarkMatches
=
"true"
SelectionMode
=
"Multiple"
TransferToID
=
"rlbPracticeSearch"
>
<
ButtonSettings
TransferButtons
=
"All"
/>
</
telerik:RadListBox
>
<
br
/>
<
br
/>
<
asp:Label
ID
=
"Label3"
runat
=
"server"
Text
=
"Time Zone:"
Visible
=
"false"
/>
<
asp:DropDownList
ID
=
"ddlTimeZone"
runat
=
"server"
Width
=
"185px"
OnChange
=
"selectItems()"
>
<
asp:ListItem
Selected
=
"True"
Text
=
"Select Practice(s) in Time Zone"
Value
=
"0"
/>
<
asp:ListItem
Text
=
"EST"
Value
=
"EST"
/>
<
asp:ListItem
Text
=
"CST"
Value
=
"CST"
/>
<
asp:ListItem
Text
=
"MST"
Value
=
"MST"
/>
<
asp:ListItem
Text
=
"PST"
Value
=
"PST"
/>
<
asp:ListItem
Text
=
"AKST"
Value
=
"AKST"
/>
<
asp:ListItem
Text
=
"HST"
Value
=
"HST"
/>
</
asp:DropDownList
>
</
td
>
<
td
align
=
"left"
valign
=
"top"
>
<
asp:Label
ID
=
"lblPracticeSearch"
runat
=
"server"
Text
=
"Practice Search:"
></
asp:Label
><
br
/>
<
telerik:RadListBox
ID
=
"rlbPracticeSearch"
runat
=
"server"
Width
=
"180px"
Height
=
"257px"
AllowTransfer
=
"True"
AllowTransferOnDoubleClick
=
"True"
EnableDragAndDrop
=
"True"
EnableMarkMatches
=
"true"
SelectionMode
=
"Multiple"
TransferToID
=
"rlbPracticeSelect"
>
<
ButtonSettings
ShowTransfer
=
"false"
ShowTransferAll
=
"false"
/>
</
telerik:RadListBox
>
<
br
/>
<
br
/>
<
asp:Label
ID
=
"lblTimeZone"
runat
=
"server"
Text
=
""
></
asp:Label
>
<
asp:CustomValidator
ID
=
"cvPractice"
runat
=
"server"
ValidationGroup
=
"SearchSummary"
Display
=
"Dynamic"
ErrorMessage
=
"Please select at least one Practice."
ClientValidationFunction
=
"ValidatePractices"
> </
asp:CustomValidator
>
</
td
>
<
tr
>
<
td
colspan
=
2
>
<
asp:Button
ID
=
"btnSort"
runat
=
"server"
Text
=
"Sort Lists"
Width
=
"80px"
/>
</
td
>
</
tr
>
</
table
>
javascript:
<telerik:RadScriptBlock ID=
"RadScriptBlock1"
runat=
"server"
>
<script language=
"javascript"
type=
"text/javascript"
>
function
filterListBox(sender, e) {
var
list = $find(
"<%= rlbPracticeSelect.ClientID %>"
);
var
tz = document.getElementById(
'<%=ddlTimeZone.ClientID %>'
);
var
items = list.get_items();
for
(
var
i = 0; i < items.get_count(); i++) {
var
item = items.getItem(i);
var
itemTimeZone = item._element.title;
item.unselect();
if
(itemTimeZone == tz.value) {
//list.transferToDestination(item);
item.select();
item.scrollIntoView();
}
}
}</script>
</telerik:RadScriptBlock>
code behind:
Private
Sub
LoadPractices()
Try
rlbPracticeSelect.Items.Clear()
rlbPracticeSearch.Items.Clear()
Dim
dt
As
DataTable = GetAllPractices()
If
dt.Rows.Count > 0
Then
With
rlbPracticeSelect
Dim
dr
As
DataRow
For
Each
dr
In
dt.Rows
Dim
rItem
As
New
RadListBoxItem(dr(
"Name"
).ToString, dr(
"ID"
).ToString)
rItem.ToolTip = dr(
"TimeZone"
).ToString
rItem.Attributes.Add(
"TimeZone"
, dr(
"TimeZone"
).ToString)
.Items.Add(rItem)
Next
End
With
End
If
Catch
ex
As
Exception
Dim
sError
As
String
= ex.Message
Finally
End
Try
End
Sub
when the sort button is clicked:
Private
Sub
btnSort_Click(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
btnSort.Click
rlbPracticeSearch.SortItems()
rlbPracticeSelect.SortItems()
Dim
itmSelect
As
RadListBoxItem
For
Each
itmSelect
In
rlbPracticeSelect.Items
itmSelect.ToolTip = itmSelect.Attributes(
"TimeZone"
)
Next
Dim
itmSearch
As
RadListBoxItem
For
Each
itmSearch
In
rlbPracticeSearch.Items
itmSearch.ToolTip = itmSearch.Attributes(
"TimeZone"
)
Next
End
Sub