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

Grid tooltip problem

1 Answer 86 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeff Tang
Top achievements
Rank 1
Jeff Tang asked on 15 Aug 2008, 06:20 AM

private void CreateToolTip()
 {
  GridDataItem DataItem;
 
  int iPageIndex = rgSNLoc.CurrentPageIndex;
  int iPageSize = rgSNLoc.MasterTableView.PageSize;
  int iFactor = iPageIndex * iPageSize;

  for (int i = iFactor; i < rgSNLoc.MasterTableView.Items.Count + iFactor; i++)
  {
   DataItem = rgSNLoc.MasterTableView.Items[i - iFactor] as GridDataItem; 

   if (sMultiAddr[i].Length == 1)
   {
    DataItem["loc_name"].ToolTip = sMultiAddr[i][0];
   }
   else
   {
    for (int j = 0; j < sMultiAddr[i].Length; j++)
    {
     if (j == sMultiAddr[i].Length - 1)
      DataItem["loc_name"].ToolTip = sMultiAddr[i][j];
     else
      DataItem["loc_name"].ToolTip = sMultiAddr[i][j] + "\n\n";
    }
   }
  }
 }

I wrote the above function and put it in the "PreRender" event handler of the RadGrid. What I want to do is to assign a unique tooltip to each row of a specified column in the grid, and the tooltip will still exist correctly even the user change the page size or switch to another page of the grid dynamically. However, if the user sort on a column, the value of the tooltips will become wrong. So how can I keep the tooltips correctly in this case? Thanks.

1 Answer, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 19 Aug 2008, 09:02 AM
Hi Jeff Tang,

From the code below I can see that your tooltips are static, i.e cells from first row always have same tooltip coming from your sMultiAddr array. Therefore after grid sorting instead the first grid row to have the tooltips from the last item of the array, it is assigned the first array item. I suggest that you handle the grid SortCommand server event and there sort your array accordingly.

Give it a try and let us know if this helps.

Find more information about RadGrid sorting in the following resources:
http://www.telerik.com/help/aspnet-ajax/grdgettingfamiliarwithserverapi.html
http://www.telerik.com/help/aspnet-ajax/grdcontrollingsortingmodes.html
http://www.telerik.com/help/aspnet-ajax/grdapplycustomsortcriteria.html

Regards,
Iana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Jeff Tang
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Share this question
or