You can display a tooltip when a user hovers over a grid item. Tooltips can provide additional context, but do not use them as the only way to communicate essential information.
Handle the ItemDataBound or ItemCreated event. Tooltips are commonly displayed for header and data cells.
To display tooltips only for header cells, check whether e.Item is a GridHeaderItem in the event handler.
To display tooltips for data items, check whether e.Item is a GridDataItem.
protectedvoidRadGrid1_NeedDataSource(object sender,GridNeedDataSourceEventArgs e){
RadGrid1.DataSource = Enumerable.Range(1,60).Select(x =>new{
ID = x,
Name ="Name "+ x,
Description ="Description for "+ x
});}protectedvoidRadGrid1_ItemDataBound(object sender,GridItemEventArgs e){//Check for GridHeaderItem if you want tooltips for the header cellsif(e.Item isGridHeaderItem){GridHeaderItem headerItem = e.Item asGridHeaderItem;foreach(GridColumn column in RadGrid1.MasterTableView.RenderColumns){
headerItem[column.UniqueName].ToolTip = column.UniqueName;}}if(e.Item isGridDataItem){GridDataItem gridItem = e.Item asGridDataItem;foreach(GridColumn column in RadGrid1.MasterTableView.RenderColumns){//this line will show a tooltip based on the ID data field
gridItem[column.UniqueName].ToolTip ="ID: "+
gridItem.GetDataKeyValue("ID").ToString();//This is in case you wish to display other row valueif(column.UniqueName =="Name"){
gridItem[column.UniqueName].ToolTip = gridItem["Description"].Text;}}}}
VB
ProtectedSub RadGrid1_NeedDataSource(sender AsObject, e As GridNeedDataSourceEventArgs)
RadGrid1.DataSource = Enumerable.Range(1,60).[Select](Function(x)NewWith{
.ID = x,
.Name="Name "& x,
.Description ="Description for "& x
})EndSubProtectedSub RadGrid1_ItemDataBound(ByVal sender AsObject,ByVal e As GridItemEventArgs)IfTypeOf e.Item Is GridHeaderItem ThenDim headerItem As GridHeaderItem =TryCast(e.Item, GridHeaderItem)For Each column As GridColumn In RadGrid1.MasterTableView.RenderColumns
headerItem(column.UniqueName).ToolTip = column.UniqueName
NextEndIfIfTypeOf e.Item Is GridDataItem ThenDim gridItem As GridDataItem =TryCast(e.Item, GridDataItem)For Each column As GridColumn In RadGrid1.MasterTableView.RenderColumns
gridItem(column.UniqueName).ToolTip ="ID: "& gridItem.GetDataKeyValue("ID").ToString()If column.UniqueName ="Name"Then
gridItem(column.UniqueName).ToolTip = gridItem("Description").TextEndIfNextEndIfEndSub
You can also add tooltips with JavaScript. To display a data key, include the field name in the ClientDataKeyNames collection. For more information, see:
The following example shows the client-side configuration:
Example: Configuring client-side tooltip events
ASP.NET
<telerik:RadGridID="RadGrid1"runat="server"AllowPaging="True"Width="800px"OnNeedDataSource="RadGrid1_NeedDataSource"><ClientSettings><%--This can be OnDataBound if you are using client-side binding--%><ClientEventsOnGridCreated="gridCreated"/></ClientSettings><MasterTableViewDataKeyNames="ID"ClientDataKeyNames="ID"></MasterTableView></telerik:RadGrid>
C#
protectedvoidRadGrid1_NeedDataSource(object sender,GridNeedDataSourceEventArgs e){
RadGrid1.DataSource = Enumerable.Range(1,60).Select(x =>new{
ID = x,
Name ="Name "+ x,
Description ="Description for "+ x
});}
VB
ProtectedSub RadGrid1_NeedDataSource(sender AsObject, e As GridNeedDataSourceEventArgs)
RadGrid1.DataSource = Enumerable.Range(1,60).[Select](Function(x)NewWith{
.ID = x,
.Name="Name "& x,
.Description ="Description for "& x
})EndSub
Telerik UI for ASP.NET AJAX provides the RadToolTip component, which can match the skin and theme of your application. It also supports dynamic AJAX loading and automatic tooltip creation for an area.