【问题标题】:Have a RadGrid need to add tooltip to column rows有一个 RadGrid 需要向列行添加工具提示
【发布时间】:2012-10-29 14:00:05
【问题描述】:

我正在使用 RadGrid。有一个名为 Comments 的列,我目前将其作为 Y/N 如果他们将鼠标悬停在评论标题行上,我喜欢添加一个工具提示。有没有一种简单的方法可以做到这一点?对于名为 CommentsY/N 的列,我的值为 Y/N。我还有一个名为“评论”的专栏,我正在隐藏它。当用户将鼠标悬停在 CommentsY/N 上时,我喜欢显示 Comments 字段的值。

到目前为止,我有以下内容:

我要做的是将鼠标悬停在注释列行上,然后显示注释,这也是网格上的绑定列。由于 cmets 可能很长,我想在用户将鼠标悬停在 Notes 上时显示它。一旦悬停工作,我将使评论字段不可见。 这就是我所拥有的,但问题是当我将鼠标悬停在注释上时,我只看到它说 Cmmts 并且它不显示给定行的注释内容。

    if (e.Item is GridDataItem)
    {
        GridDataItem gridItem = e.Item as GridDataItem;
        foreach (Telerik.Web.UI.GridColumn column in WtrClients.MasterTableView.RenderColumns)
        {
            if (column is GridBoundColumn)
            {
                //this line will show a tooltip based on the CustomerID data field
                if (column.UniqueName == "Notes")
                {
                    gridItem[column.UniqueName].ToolTip = "Cmmts:" + 
                        Convert.ToString(gridItem.OwnerTableView.DataKeyValues[gridItem.ItemIndex]["Comments"]);
                }

            }
        }
    }

【问题讨论】:

    标签: telerik telerik-grid


    【解决方案1】:

    您可以在网格中执行Label ItemTemplate,评估您的cmets 中是否有任何内容以显示YN,然后设置工具提示。 :

    <ItemTemplate>
    <asp:Label ID="lblOnGrid" runat="server" Text='<%#Convert.ToString(Eval("comments_column")).Equals("") ? "N" : "Y" %>'                                
    ToolTip='<%#Eval("comments_column")%>'>
    </asp:Label>
    </ItemTemplate>
    

    【讨论】:

    • IMO,这是最好的方法!
    【解决方案2】:

    Telerik 在他们的网站上有一个演示,其中应该包含完成此操作所需的一切:)

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

    没有平台标签,所以我假设(根据您的用户名进行更多猜测)ASP.NET

    【讨论】:

    • 感谢您的评论。我已经添加了我尝试过的内容。基本上我试图将鼠标悬停在注释行上,然后显示给定行的注释。我没有显示任何 cmets。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-10-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-12
    相关资源
    最近更新 更多