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

Tooltip lost after SortItems (with workaround)

2 Answers 55 Views
This is a migrated thread and some comments may be shown as answers.
Matthew Johnson
Top achievements
Rank 1
Matthew Johnson asked on 04 Nov 2010, 03:49 PM

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 :

     <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"  />
                <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" />
     <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" />
                <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  colspan=2>
          <asp:Button ID="btnSort" runat="server" Text="Sort Lists" Width="80px" />

<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;
                if (itemTimeZone == tz.value) {

code behind:
Private Sub LoadPractices()
        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)
            End With
        End If
    Catch ex As Exception
        Dim sError As String = ex.Message
    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
    Dim itmSelect As RadListBoxItem
    For Each itmSelect In rlbPracticeSelect.Items
        itmSelect.ToolTip = itmSelect.Attributes("TimeZone")
    Dim itmSearch As RadListBoxItem
    For Each itmSearch In rlbPracticeSearch.Items
        itmSearch.ToolTip = itmSearch.Attributes("TimeZone")
End Sub

2 Answers, 1 is accepted

Sort by
Genady Sergeev
Telerik team
answered on 09 Nov 2010, 01:31 PM
Hi Matthew Johnson,

Could you please specify which version of the controls do you use? There used to be a similar issue with tooltips, when one is transferring items on the client, however, we have fixed it for the latest version.

Sincerely yours,
Genady Sergeev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Matthew Johnson
Top achievements
Rank 1
answered on 10 Nov 2010, 08:18 PM
Sorry about that... I should have included that in my original post.

I'm currently using version 2010.2.713.35. 

I've haven't had time to upgrade to the latest version, but it's nice to know it's already been addressed.

Asked by
Matthew Johnson
Top achievements
Rank 1
Answers by
Genady Sergeev
Telerik team
Matthew Johnson
Top achievements
Rank 1
Share this question