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

rad tooltip for selected cells of radgrid

1 Answer 243 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
udaya
Top achievements
Rank 1
udaya asked on 07 Apr 2009, 04:41 AM

   Hi,

      I want to add the rad tooltip for the selected cell of radgrid.

      My problem is :i m getting tooltip for every cell.i want to diplay
 
      tooltip for selected cell only.

      I used the following javascript to select the multiple cells of
      the radgrid.

      Here is the javascript code:
     

         <script type="text/javascript">
   
    function RowCreated(sender, eventArgs)
     {
         var dataItem = eventArgs.get_gridDataItem();
       
        for (var i = 0; i < dataItem.get_element().cells.length; i++)
       
           {
                dataItem.get_element().cells[i].onclick = function()
              {
                this.selected = this.selected == true ? false : true;
                this.className = "ClickClass";
            };
        }
    }
</script>

    and in client settings of rad grid
    ----------------------------------

 

<ClientSettings>
   <Selecting AllowRowSelect="false" ></Selecting>
  
   <ClientEvents OnRowCreated = "RowCreated" ></ClientEvents>
</ClientSettings>

 

     and for tooltip i used the following code:
     ------------------------------------------

protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {

     
          if (e.Item is GridDataItem)
            {

               foreach (GridTableCell cell in e.Item.Cells)
              {

                   cell.ToolTip = cell.Text;

                }
            }

        }

 

      so...instead of this how to get the tooltip of radgrid.....when the cell is selected?

      pls ..help me to solve this prob..

    thanks in advance

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 07 Apr 2009, 09:57 AM
Hello Udaya,

You can actually add a line of code as shown below to the client side code you have implemented as shown below to set the tooltip for the selected cell rather than setting the tooltip on the server side :
js:
 function RowCreated(sender, eventArgs) 
     { 
         var dataItem = eventArgs.get_gridDataItem();        
         for (var i = 0; i < dataItem.get_element().cells.length; i++)        
           { 
              dataItem.get_element().cells[i].onclick = function() 
              { 
                this.selected = this.selected == true ? false : true
                this.className = "ClickClass"
                this.title = this.innerText; 
              }; 
        } 
    } 

Thanks
Princy.
Tags
ToolTip
Asked by
udaya
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or