1

如何为 RadGrid 行设置 RadToolTip?

<asp:Label ID="lblCustomerName" runat="server" Text='<%# Eval("CustomerName") %>'>
</asp:Label>
<telerik:RadToolTip ID="RadToolTip3" runat="server" TargetControlID="lblCustomerName" 
    Width="400px" RelativeTo="Element" Position="BottomCenter"  AutoCloseDelay="50000">
             this is some content
</telerik:RadToolTip>
4

3 回答 3

2

挂钩 ItemCreated 事件,该事件为 RadGrid 中的每一行触发。然后您可以看到该行的工具提示。

protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem gridItem = e.Item as GridDataItem;
        foreach (GridColumn column in RadGrid1.MasterTableView.RenderColumns)
        {
            if (column is GridBoundColumn)
            {
                //this line will show a tooltip based on the CustomerID data field
                gridItem[column.UniqueName].ToolTip = "CustomerID: " + 
                    gridItem.OwnerTableView.DataKeyValues[gridItem.ItemIndex]["CustomerID"].ToString();

                //This is in case you wish to display the column name instead of data field.
                //gridItem[column.UniqueName].ToolTip = "Tooltip: " + column.UniqueName;
            }
        }
    }
}

http://www.telerik.com/help/aspnet-ajax/grid-appearance-tooltips-for-grid-items.html

于 2013-05-08T16:19:40.483 回答
0
protected void rgCareActivity_ItemDataBound(object source, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem item = e.Item as GridDataItem;

        Control target = e.Item.FindControl("lblCustomerName");
        if (!Object.Equals(target, null))
        {
            if (!Object.Equals(this.RadToolTip3, null))
            {
                //Add the button (target) id to the tooltip 
                this.RadToolTip3.TargetControls.Add(target.ClientID, (e.Item as GridDataItem).GetDataKeyValue("ID").ToString(), true);
            }
        }
    }
}

protected void RadToolTip3_AjaxUpdate(object sender, ToolTipUpdateEventArgs e)
{    
    string strValue = e.Value;
    RadToolTip3.Text = strValue ;
}
于 2014-07-10T14:14:13.877 回答
0

你可以试试这个。

protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem gridItem = e.Item as GridDataItem;
        Control lblItem = gridItem.FindControl("lblCustomerName");
        Control toolTipItem = gridItem.FindControl("RadToolTip3");
        if (!Object.Equals(lblItem , null) && !Object.Equals(toolTipItem , null))
        {
            ((RadToolTip)toolTipItem).TargetControlID = lblItem.ID;
        }
    }
}
于 2016-02-04T03:53:55.627 回答