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

[Solved] tooltip in radgrid

1 Answer 174 Views
Grid
This is a migrated thread and some comments may be shown as answers.
giancarlo
Top achievements
Rank 1
giancarlo asked on 16 Jun 2009, 07:56 PM

The tooltip works but its not displaying any dynamic data.   i converted from csharp to vb.net.  perhaps i messed up something.
let me know if you spot any errors

page with radgrid code_________________

<

 

asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">

 

 

<ContentTemplate>

 

 

<telerik:RadToolTipManager ID="RadToolTipManager1" OffsetY="-1" HideEvent=ManualClose

 

 

Width="250" Height="350" runat="server" OnAjaxUpdate="OnAjaxUpdate" RelativeTo="Element"

 

 

Position="MiddleRight">

 

 

</telerik:RadToolTipManager>

 

 

<div class="title">For Sale by <br />

 

 

<telerik:RadComboBox ID="RadComboBox1" Runat="server" AutoPostBack="True">

 

 

<Items>

 

 

<telerik:RadComboBoxItem runat="server" Text="By Woodmizer" Value="1" />

 

 

<telerik:RadComboBoxItem runat="server" Text="By Owner" Value="2" />

 

 

</Items>

 

 

</telerik:RadComboBox>

 

 

<br />

 

By Group

<br /><telerik:RadComboBox ID="RadComboBox2" AutoPostBack="True" Runat="server">

 

 

<Items>

 

 

<telerik:RadComboBoxItem runat="server" Text="Select All" Value="%" />

 

 

<telerik:RadComboBoxItem runat="server" Text="Manual Feed"

 

 

Value="Manual Feed" />

 

 

<telerik:RadComboBoxItem runat="server" Text="Power Feed" Value="Power Feed" />

 

 

<telerik:RadComboBoxItem runat="server" Text="Hydraulic" Value="Hydraulic" />

 

 

<telerik:RadComboBoxItem runat="server" Text="High Production"

 

 

Value="High Production" />

 

 

 

</Items>

 

 

</telerik:RadComboBox>

 

 

<br />

 

 

<br />

 

 

<br />

 

 

<telerik:RadGrid ID="RadGrid1" Width="600" runat="server" DataSourceID="SqlDataSource1"

 

 

GridLines="None" OnItemDataBound="RadGrid1_ItemDataBound" AllowPaging="true" OnItemCreated="RadGrid1_ItemCreated"

 

 

AllowSorting="true" PageSize="10" OnItemCommand="RadGrid1_ItemCommand">

 

 

<MasterTableView

 

 

AutoGenerateColumns="False"

 

 

CommandItemDisplay="None"

 

 

CurrentResetPageIndexAction="SetPageIndexToFirst"

 

 

DataKeyNames="ProductID"

 

 

ClientDataKeyNames="ProductID"

 

 

DataSourceID="SqlDataSource1"

 

 

Dir="LTR"

 

 

Frame="Border"

 

 

TableLayout="Auto">

 

 

<Columns>

 

 

<telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="ProductID" Display="false"

 

 

DataType="System.Int32" FilterListOptions="VaryByDataType" ForceExtractValue="None"

 

 

HeaderText="ProductID" ReadOnly="True" SortExpression="ProductID" UniqueName="ProductID">

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridTemplateColumn HeaderText="Product">

 

 

<ItemTemplate>

 

 

<asp:HyperLink ID="targetControl" runat="server" NavigateUrl="#" Text='<%# Eval("item") %>'></asp:HyperLink>

 

 

</ItemTemplate>

 

 

</telerik:GridTemplateColumn>

 

 

<telerik:GridBoundColumn DataField="grp" HeaderText="Group" SortExpression="grp"

 

 

UniqueName="grp">

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn DataField="manuf_year" DataType="System.Int32"

 

 

HeaderText="Yr." ReadOnly="True" SortExpression="manuf_year"

 

 

UniqueName="manuf_year">

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn DataField="mill_hours" HeaderText="Hrs."

 

 

SortExpression="mill_hours" UniqueName="mill_hours">

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn DataField="destination" HeaderText="Location"

 

 

SortExpression="destination" UniqueName="destination">

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridBoundColumn DataField="price" DataType="System.Decimal"

 

 

HeaderText="Price" ReadOnly="True" SortExpression="price" DataFormatString="{0:C}"

 

 

UniqueName="price">

 

 

</telerik:GridBoundColumn>

 

 

<telerik:GridTemplateColumn

 

 

UniqueName="TemplateEditColumn">

 

 

<ItemTemplate>

 

 

<asp:HyperLink ID="EditLink" runat="server" Text="View Details"></asp:HyperLink>

 

 

</ItemTemplate>

 

 

</telerik:GridTemplateColumn>

 

 

</Columns>

 

 

 

</MasterTableView>

 

 

</telerik:RadGrid>

 

 

 

<telerik:RadWindowManager ID="RadWindowManager1" runat="server">

 

 

<Windows>

 

 

<telerik:RadWindow ID="UserListDialog" runat="server" Title="Editing record" Height="800px"

 

 

Width="800px" Left="150px" ReloadOnShow="true" ShowContentDuringLoad="false" Modal="true" />

 

 

</Windows>

 

 

</telerik:RadWindowManager>

 

 

 

</ContentTemplate>

 

 

</asp:UpdatePanel>

code behind________

 

Protected

 

Sub OnAjaxUpdate(ByVal sender As Object, ByVal args As ToolTipUpdateEventArgs)

 

 

Me.UpdateToolTip(args.Value, args.UpdatePanel)

 

 

End Sub

 

 

 

 

 

Private Sub UpdateToolTip(ByVal elementID As String, ByVal panel As UpdatePanel)

 

 

Dim ctrl As Control = Page.LoadControl("ProductDetails.ascx")

 

panel.ContentTemplateContainer.Controls.Add(ctrl)

 

Dim details As ProductDetails = DirectCast(ctrl, ProductDetails)

 

details.ProductID = elementID

 

End Sub

 

 

 

 

 

Protected Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As GridItemEventArgs)

 

 

If TypeOf e.Item Is GridDataItem Then

 

 

 

 

 

Dim editLink As HyperLink = DirectCast(e.Item.FindControl("EditLink"), HyperLink)

 

editLink.Attributes(

"href") = "#"

 

 

 

 

editLink.Attributes(

"onclick") = [String].Format("return ShowEditForm('{0}','{1}');", e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("ProductID"), e.Item.ItemIndex)

 

 

End If

 

 

 

 

 

End Sub

 

 

 

 

 

Protected Sub RadGrid1_ItemDataBound(ByVal sender As Object, ByVal 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

 

 

 

 

 

Dim currentRow As DataRowView = DirectCast(e.Item.DataItem, DataRowView)

 

 

Me.RadToolTipManager1.TargetControls.Add(target.ClientID, currentRow.Row("ProductID").ToString(), True)

 

 

End If

 

 

 

 

 

End If

 

 

 

 

 

End If

 

 

 

 

 

End Sub

 

 

 

 

 

Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As GridCommandEventArgs)

 

 

If e.CommandName = "Sort" OrElse e.CommandName = "Page" Then

 

 

 

 

RadToolTipManager1.TargetControls.Clear()

 

End If

 

 

 

 

 

End Sub

 

 

 

_____________________________________________________________________

ProductDetails.ascx__________________

 

<%

@ Control Language="vb" AutoEventWireup="false" CodeBehind="ProductDetails.ascx.vb" Inherits="UsedMills.ProductDetails" %>

 

 

 

<

 

table runat="server" style="width: 100%" id="ProductWrapper" border="0" cellpadding="2"

 

 

 

 

 

cellspacing="0">

 

 

 

 

 

<tr>

 

 

 

 

 

<td style="text-align: center;">

 

 

 

 

 

<asp:FormView ID="ProductsView" DataSourceID="ProductDataSource" DataKeyNames="ProductID"

 

 

 

 

 

runat="server" OnDataBound="ProductsView_DataBound">

 

 

 

 

 

<ItemTemplate>

 

 

 

 

 

<asp:Label ID="Category" runat="server"><%#Eval("ITEM")%></asp:Label>

 

 

 

 

 

<hr />

 

 

 

 

 

<asp:Image ID="image" Width="200" Height="200" runat="server" ImageUrl='<%# Eval("ProductID", "../../../Img/Northwind/Products/{0}") %>' />

 

 

 

 

 

<br />

 

 

 

 

 

<span >Units On Order:</span>

 

 

 

 

 

<asp:Label ID="Label4" runat="server"><%#Eval("description")%></asp:Label>

 

 

 

 

 

</ItemTemplate>

 

 

 

 

 

</asp:FormView>

 

 

 

 

 

</td>

 

 

 

 

 

</tr>

 

</

 

table>

 

<

 

asp:SqlDataSource ID="ProductDataSource" runat="server"

 

 

ConnectionString="<%$ ConnectionStrings:wmConnectionString %>"

 

 

SelectCommand="wmUMSaleBySearchID" SelectCommandType="StoredProcedure">

 

 

 

 

 

<SelectParameters>

 

 

 

 

 

<asp:Parameter Name="ProductID" Type="Int32" />

 

 

 

 

 

</SelectParameters>

 

</

 

asp:SqlDataSource>

 

 

 


____________________________________________________________________________

code behind____________________

 

 

 

 

 

Public Property ProductID() As String

 

 

 

 

 

 

 

 

 

 

Public

 

Property ProductID() As String

 

 

 

 

 

 

Get

 

 

 

 

 

 

If ViewState("ProductID") Is Nothing Then

 

 

 

 

 

 

Return ""

 

 

 

 

 

 

End If

 

 

 

 

 

 

Return DirectCast(ViewState("ProductID"), String)

 

 

End Get

 

 

 

 

 

 

Set(ByVal value As String)

 

 

ViewState(

"ProductID") = value

 

 

End Set

 

 

 

 

 

 

End Property

 

 

 

 

 

 

 

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

 

 

Me.ProductDataSource.SelectParameters("ProductID").DefaultValue = Me.ProductID

 

 

Me.DataBind()

 

 

End Sub

 

 

 

 

 

 

 

Protected Sub ProductsView_DataBound(ByVal sender As Object, ByVal e As EventArgs)

 

 

Dim image As System.Web.UI.WebControls.Image = DirectCast(ProductsView.FindControl("image"), System.Web.UI.WebControls.Image)

 

 

If image Is Nothing Then

 

 

 

 

 

 

Exit Sub

 

 

 

 

 

 

End If

 

 

 

 

 

 

If Not File.Exists(MapPath(image.ImageUrl)) Then

 

 

 

 

 

image.ImageUrl =

"../../Img/Northwind/Products/noimage.jpg"

 

 

 

 

 

 

End If

 

 

 

 

 

 

End Sub

 

 

End

 

Class

 

 

 

 

 









 

1 Answer, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 19 Jun 2009, 02:16 PM
Hello giancarlo,

You can examine the integration demo of RadGrid and RadToolTip linked below:

http://demos.telerik.com/aspnet-ajax/tooltip/examples/targetcontrolsandajax/defaultcs.aspx

and use it as a starting point for your implementation. Note that it has C# and VB.NET version available in the local installation of RadControls for ASP.NET AJAX at this default location:

C:\Program Files\telerik\RadControls for ASPNET AJAX Q1 2009\Live Demos\Tooltip\Examples\TargetControlsAndAjax

Kind regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
giancarlo
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Share this question
or