Tooltip over gridrow

3 posts, 0 answers
  1. Mario
    Mario avatar
    75 posts
    Member since:
    Jun 2009

    Posted 05 Oct 2009 Link to this post

    Hi,

    is it possible to assign a tooltip to a whole gridrow?

    So the user doesn't have to move the mouse over a specific control in a column of the gridrow.

    thx, Mario
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 06 Oct 2009 Link to this post

    Hello Mario,

    You could try the following code to set a tool tip for each row of grid.

    CS:
     
     protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)  
        {  
            if (e.Item is GridDataItem)  
            {  
                GridDataItem dataItem1 = (GridDataItem)e.Item;          
                dataItem1.Attributes.Add("onMouseOver""return showToolTip('"+dataItem1.ClientID +"');");  
                  
            }  
        }  

    JavaScript:
     
    <script type="text/javascript">  
    function showToolTip(ID)  
    {   
       var tooltip = $find("<%=RadToolTip1.ClientID %>");  
       tooltip.set_targetControlID(ID);  
    }  
    </script>  

    -Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mario
    Mario avatar
    75 posts
    Member since:
    Jun 2009

    Posted 06 Oct 2009 Link to this post

    hm yes maybe but i need to set the text of the tooltip dynamically in code behind of every tooltip for each row.

    i tried the telerik online demo "tooltipified grid" way:

    http://demos.telerik.com/aspnet-ajax/tooltip/examples/targetcontrolsandajax/defaultcs.aspx?product=grid

    and created following DocumentInfo.ascx to show in the tooltip of the tooltipmanager:

    using System; 
    using System.Collections; 
    using System.Configuration; 
    using System.Data; 
    using System.Linq; 
    using System.Web; 
    using System.Web.Security; 
    using System.Web.UI; 
    using System.Web.UI.HtmlControls; 
    using System.Web.UI.WebControls; 
    using System.Web.UI.WebControls.WebParts; 
    using System.Xml.Linq; 
    using EDMS.Logic.BL; 
    using EDMS.Logic.DAL; 
     
    namespace EDMS.Web.Controls 
        public partial class DocumentInfo : System.Web.UI.UserControl 
        { 
            protected void Page_Load(object sender, EventArgs e) 
            { 
                if(!IsPostBack) 
                    BindTo(); 
            } 
     
            public string DocumentId { getset; } 
     
            private void BindTo() 
            { 
                Document doc = BLDocument.GetDocument(Convert.ToInt32(DocumentId)); 
     
                if (doc != null
                { 
                    if (doc.User != null
                        lblCreater2.Text = doc.User.firstname + " " + doc.User.lastname; 
                    else 
                        lblCreater1.Text = ""
                } 
            } 
        } 
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="DocumentInfo.ascx.cs" Inherits="EDMS.Web.Controls.DocumentInfo" %> 
     
    <table> 
        <tr> 
            <td>dsfdsfdf 
                <asp:Label id="lblCreater1" runat="server" Text="Creater:"></asp:Label> 
            </td> 
            <td> 
                <asp:Label id="lblCreater2" runat="server" Text=""></asp:Label> 
            </td> 
        </tr> 
    </table> 

    I added the griditem as follows on the page where the grid is situated, like in the example so the tooltip show at the whole gridrow, which is working fine.

    protected void RadGridFavored_ItemDataBound(object sender, GridItemEventArgs e) 
            { 
                if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem) 
                { 
                    Control target = e.Item; 
                    if (!Object.Equals(target, null)) 
                    { 
                        if (!Object.Equals(this.tipManager, null)) 
                        { 
                            //Add the button (target) id to the tooltip manager 
                            this.tipManager.TargetControls.Add(target.ClientID, (e.Item as GridDataItem).GetDataKeyValue("id").ToString(), true); 
     
                        } 
                    } 
                } 
            } 

    protected void OnAjaxUpdate(object sender, ToolTipUpdateEventArgs args) 
            { 
                this.UpdateToolTip(args.Value, args.UpdatePanel); 
            } 
     
    private void UpdateToolTip(string elementID, UpdatePanel panel) 
            { 
                DocumentInfo info = new DocumentInfo(); 
                info.DocumentId = elementID; 
                panel.ContentTemplateContainer.Controls.Add(info); 
            } 


    But when the tooltip shows up its empty.

    When i debug my DocumentInfo.ascx its controls are empty in the PageLoad ... lblCreater = null

    Not even the dsfdsfdf string inside the tabledata of the ascx is shown in the tooltip.

    anyone knows why my ascx is empty?

    thx, Mario
Back to Top