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

Tooltips on a Particular Cell Not Working

2 Answers 103 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 11 Jun 2012, 01:09 PM
I am transitioning code from Microsoft's GridView to Telerik's RadGrid.  One thing I'm stuck on is how to add a Tooltip to a particular cell.   did find this article but the advice therein is not working for me: http://www.telerik.com/community/forums/aspnet/grid/radgrid-tooltip-on-cell.aspx

Here's the crux of the code I'm using:

protected void radGrid_ItemDataBound(object sender, GridItemEventArgs e)
    {
      if (e.Item is GridDataItem)
      {
        GridDataItem item = (GridDataItem)e.Item;
        item.Cells[1].ToolTip = "Sample Tooltip";


But, as I said above, no tooltip appears.  What should I do instead?

Robert

2 Answers, 1 is accepted

Sort by
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 11 Jun 2012, 05:27 PM
Hello Robert,

Please check below code snippet.
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" OnNeedDataSource="RadGrid1_NeedDataSource"
           OnItemDataBound="RadGrid1_ItemDataBound">
           <MasterTableView>
               <Columns>
                   <telerik:GridBoundColumn DataField="ID" UniqueName="ID" HeaderText="ID">
                   </telerik:GridBoundColumn>
               </Columns>
           </MasterTableView>
       </telerik:RadGrid>
protected void RadGrid1_NeedDataSource(object sender, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
        {
            DateTime dt = DateTime.Today;
 
            dynamic data = new[] {
              new { ID = 1, Name ="name1",CustomDate=dt},
              new { ID = 2, Name = "name2",CustomDate=dt.AddDays(-1)},
              new { ID = 3, Name = "name3",CustomDate=dt.AddDays(-2)},
              new { ID = 4, Name = "Name4",CustomDate=dt.AddDays(-3)},
               new { ID = 5, Name ="name5",CustomDate=dt}
            };
            RadGrid1.DataSource = data;
        }
 
       
 
        protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem item = (GridDataItem)e.Item;
                item["ID"].ToolTip = "Sample Tooltip"; // get column by unique name
            }
}



Thanks,
Jayesh Goyani
0
Robert
Top achievements
Rank 1
answered on 17 Jul 2012, 11:49 PM
Jayesh,

Sorry for the delay in replying.  I got caught up with other things and only today did I read your solution.  It works perfectly!  I wasn't aware that specifying a "UniqueID" for a field was the perfect way of accessing it via the GridDataItem array.

Thank YOU!

Robert
Tags
Grid
Asked by
Robert
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Robert
Top achievements
Rank 1
Share this question
or