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

RadGrid の行ごとに発生する ItemCreated イベントをフックします。次に、その行のツールチップが表示されます。

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 に答える