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

ToolTip Not Refreshing After Initial Call

2 Answers 17 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
Rob
Top achievements
Rank 1
Rob asked on 29 Oct 2013, 07:20 PM
I've created a simple page with a RadGrid and a RadToolTipManager on it.  What I'm trying to accomplish is very simple.  Each row in the grid has an ID and GridImageColumn.  When the image is clicked, the ID should display in the ToolTip window.  The issue I'm experiencing is after the first ToolTip is displayed, all subsequent attempts to display ToolTips always display the first ToolTip that was displayed, not the ToolTip for the row clicked.  So if 3 is clicked, I'd expect to see 3 in the ToolTip.  If 2 is clicked, I'd expect to see 2 in the Tooltip and so on. 

Here is a video recording displaying the behavior of the issue.  If I refresh the page, I can start all over again.

http://screencast.com/t/4zuJtxgGGGUW

rttm.aspx

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="rttm.aspx.vb" Inherits="rttm" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head runat="server">
 <title></title>
</head>
<body>
 <form id="form1" runat="server">
 <div>
 <telerik:RadScriptManager runat="server" ID="mgrJS" AsyncPostBackTimeout="600">
 </telerik:RadScriptManager>
 <telerik:RadGrid runat="server" ID="rg" AutoGenerateColumns="False" Width="620px" Skin="Web20">
 <MasterTableView HierarchyLoadMode="ServerOnDemand" Width="620px" TableLayout="Auto" DataKeyNames="ID">
 <Columns>
 <telerik:GridBoundColumn HeaderText="ID" UniqueName="ID" DataField="ID">
 </telerik:GridBoundColumn
<telerik:GridImageColumn UniqueName="View" ImageUrl="App_Themes/BlueBT2009/Images/Inq.gif"></telerik:GridImageColumn>
 </Columns>
 </MasterTableView>
 <FilterMenu EnableImageSprites="False">
 </FilterMenu>
 </telerik:RadGrid>
 <telerik:RadToolTipManager ID="RadToolTipManager1" OffsetY="-1" HideEvent="Default"
 Width="800px" Height="600px" runat="server" EnableShadow="true" RelativeTo="BrowserWindow"
 Position="Center" OnAjaxUpdate="Load_ToolTip" 
Modal="false" ContentScrolling="Auto" AutoCloseDelay="0" ShowEvent="OnClick" >
 </telerik:RadToolTipManager>
 </div>
 </form>
</body>
</html>

rttm.aspx.vb

Partial Class rttm
 Inherits System.Web.UI.Page
 Protected Sub rg_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles rg.ItemDataBound
If e.Item.ItemType = GridItemType.Item OrElse e.Item.ItemType = GridItemType.AlternatingItem Then
 Me.RadToolTipManager1.TargetControls.Add(TryCast(e.Item, GridDataItem)("View").ClientID, TryCast(e.Item, GridDataItem)("ID").Text, True)
End If
 End Sub
 Protected Sub rg_NeedDataSource(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles rg.NeedDataSource
Dim dt As New DataTable()
Dim col As New DataColumn("ID")
dt.Columns.Add(col)
Dim row As DataRow = dt.NewRow
row(0) = 1
dt.Rows.Add(row)
row = dt.NewRow
row(0) = 2
dt.Rows.Add(row)
row = dt.NewRow
row(0) = 3
dt.Rows.Add(row)
Me.rg.DataSource = dt
Session("rttm") = dt
End Sub
 Protected Sub Load_ToolTip(ByVal sender As Object, ByVal args As ToolTipUpdateEventArgs)
Dim invoiceDetails() As String = args.Value.Split("_")
Dim toAdd As UserControl = LoadUserControl("rttmdetails.ascx", invoiceDetails)
args.UpdatePanel.ContentTemplateContainer.Controls.Add(toAdd)
args.UpdatePanel.Update()
End Sub
 Private Function LoadUserControl(ByVal UserControlPath As String, ByVal ParamArray constructorParameters As Object()) As UserControl
Dim constParamTypes As New List(Of Type)()
For Each constParam As Object In constructorParameters
constParamTypes.Add(constParam.[GetType]())
Next
 Dim ctl As UserControl = TryCast(Page.LoadControl(UserControlPath), UserControl)
Dim constructor As System.Reflection.ConstructorInfo = ctl.[GetType]().BaseType.GetConstructor(constParamTypes.ToArray())
If constructor Is Nothing Then
 Throw New MemberAccessException("The requested constructor was not found on : " & ctl.[GetType]().BaseType.ToString())
Else
constructor.Invoke(ctl, constructorParameters)
End If
 Return ctl
End Function
End Class

rttmDetails.aspx

<%@ Control Language="VB" AutoEventWireup="false" CodeFile="rttmDetails.ascx.vb" Inherits="rttmDetails" %>
<telerik:RadGrid ID="rg" runat="server" AutoGenerateColumns="false" Skin="Web20" AllowMultiRowSelection="true">
<MasterTableView Name="details" DataKeyNames="ID">
 <Columns>
 <telerik:GridBoundColumn HeaderText="ID" UniqueName="ID" DataField="ID">
 </telerik:GridBoundColumn>
 </Columns>
</MasterTableView>
</telerik:RadGrid>

rttmDetails.aspx.vb

Partial Class rttmDetails
 Inherits System.Web.UI.UserControl
 Private _id As String
 Public Property Identity() As String
 Get
 Return (_id)
End Get
 Set(ByVal value As String)
_id = value
End Set
 End Property
 Private _details As DataRow()
ReadOnly Property Details() As DataRow()
Get
 Return _details
End Get
 End Property
 Public Sub New()
End Sub
 Public Sub New(ByVal id As String)
Dim dt As DataTable = CType(Session("rttm"), DataTable)
_id = id
_details = dt.Select("ID=" & id)
End Sub
 Protected Sub rgInvoice_NeedDataSource(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles rg.NeedDataSource
Me.rg.DataSource = Details
End Sub
End Class

I'm sure this is a common issue that should have an easy fix.  I'm anxiously awaiting your answer.

Thanks,
Rob

2 Answers, 1 is accepted

Sort by
0
Accepted
Marin Bratanov
Telerik team
answered on 29 Oct 2013, 09:24 PM
Hi Rob,

This article can explain the problem: http://www.telerik.com/help/aspnet-ajax/tooltip-troubleshooting-common-issues.html. The Controls loaded via AJAX retain old values section is what you need. Said shortly, you need to use the OnPreRender event of the user control to bind new data to the grid, otherwise it will be taken from the ViewState, i.e. from the first shown tooltip.


Regards,
Marin Bratanov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Rob
Top achievements
Rank 1
answered on 30 Oct 2013, 01:41 PM
Your recommendation works for me!  Thank you!
Tags
ToolTip
Asked by
Rob
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Rob
Top achievements
Rank 1
Share this question
or