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

[Solved] ToolTip & Grid Sorting

1 Answer 99 Views
Grid
This is a migrated thread and some comments may be shown as answers.
silver chan
Top achievements
Rank 1
silver chan asked on 06 Jan 2010, 06:25 AM
I have problem with using ToolTip & Grid

First i have function to update the grid and i will call at page load (not postback)
Protected Sub UpdateGV()  
 
            cmd = New SqlCommand("Select * From View_DIS_GROUP Order By SEQ")  
            Me.RadGrid1.MasterTableView.DataKeyNames = New String() {"UID"}  
 
            Update_GV_Global(cmd, Me.RadGrid1)  
 
            'rebind will add ToolTip again  
            Me.RadToolTipManager1.TargetControls.Clear()  
 
            Me.RadGrid1.MasterTableView.GetColumnSafe("UID").Visible = False 
            Me.RadGrid1.MasterTableView.GetColumnSafe("GROUP_NAME").HeaderText = "群組名稱" 
            Me.RadGrid1.MasterTableView.GetColumnSafe("SEQ").HeaderText = "次序" 
            Me.RadGrid1.MasterTableView.GetColumnSafe("counter").HeaderText = "群組人數" 
            Me.RadGrid1.Rebind()  
         
End sud   
 

and also i will call it in Sorting

Protected Sub RadGrid1_SortCommand(ByVal source As ObjectByVal e As Telerik.Web.UI.GridSortCommandEventArgs) Handles RadGrid1.SortCommand  
 
        UpdateGV()  
 
 End Sub 
 
 

i adding tooltip at ItemDataBound

Protected Sub RadGrid1_ItemDataBound(ByVal sender As ObjectByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound  
 
If TypeOf e.Item Is GridDataItem Then 
 
    Me.RadToolTipManager1.TargetControls.Add(dataItem("counter").ClientID, dataItem("UID").Text, True)  
 
end if  
 
End Sub 
 

i find that if i sort the data in the Grid ,The tooltip will going wrong context.
Like:

First Page Load
Grid Item/  ToolTip Context    
1            1
2            2
3            3
4            4
5            5
*Context Match

First Sort
Grid Item/  ToolTip Context    
5            1
4            2
3            3
2            4
1            5
*Context Wrong

Second Sort
Grid Item/  ToolTip Context    
1            5
2            4
3            3
4            2
5            1
*Context Wrong but match first sort
Can anyone help me? Thanks!

1 Answer, 1 is accepted

Sort by
0
Mira
Telerik team
answered on 07 Jan 2010, 03:10 PM
Hello Silver,

To set the correct tooltip after sorting, please clear the RadToolTipManager's TargetControls collection  because the records on the sorted grid have the same ClientIDs as the old ones. This should be done for paging as well.
The code for reseting the tooltips should look like:
Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs)
            If e.Item.ItemType = GridItemType.Item OrElse e.Item.ItemType = GridItemType.AlternatingItem Then
                Dim target As Control = e.Item.FindControl("targetControl")
                If Not [Object].Equals(target, Nothing) Then
                    If Not [Object].Equals(Me.RadToolTipManager1, Nothing) Then
                        'Add the button (target) id to the tooltip manager
                        Me.RadToolTipManager1.TargetControls.Add(target.ClientID, (TryCast(e.Item, GridDataItem)).GetDataKeyValue("<DataKeyName>").ToString(), True)
                    End If
                End If
            End If
        End Sub
  
        Protected Sub RadGrid1_ItemCommand(source As Object, e As GridCommandEventArgs)
            If e.CommandName = "Sort" OrElse e.CommandName = "Page" Then
                RadToolTipManager1.TargetControls.Clear()
            End If
  
        End Sub

I hope this helps.

Kind regards,
Mira
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
silver chan
Top achievements
Rank 1
Answers by
Mira
Telerik team
Share this question
or