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

Tooltip + RadGrid + OnAjaxUpdate + Paging = not working properly

4 Answers 109 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
Guido S
Top achievements
Rank 1
Guido S asked on 05 May 2011, 10:38 AM
Hello,

Im having a problem using a ToolTip in a Radgrid that has paging enabled. Everything works fine on the first page, but just fails to work at the other pages. I have tried several things like checking the itemIndex + pagesize and on what i currently am.

I can not supply all the code, but this should do it. Its about the tooltip manager i think. ItemDataBound triggers the FillData.

private void FillData(GridItem repItem)
   {
 
           if (repItem.ItemType == Telerik.Web.UI.GridItemType.AlternatingItem || repItem.ItemType == Telerik.Web.UI.GridItemType.Item)
            {
                NameView nameView= (NameView) repItem.DataItem;
 
   
                pnlImage.ID = nameView.Id.ToString();
 
                    if (this.EnableMouseOver)
                    {
                      tooltipManager.TargetControls.Add(pnlImage.ClientID, nameView.Id.ToString(), true);
                    }
               }
           }  
    }

Im pretty sure its a small thing i am missing.

Ive also used this around it.

if (_itemIndex >= (_currentPage * repItem.OwnerTableView.PageSize))
 {
     if (this.EnableMouseOver)
     {
       tooltipManager.TargetControls.Add(pnlImage.ClientID, nameView.Id.ToString(), true);
     }
}
 _itemIndex++;

The OnAjaxUpdate works fine since it works on the first page of the grid.

<telerikAjax:RadToolTipManager ID="tooltipManager" runat="server" AnimationDuration="300" Animation="Fade" ShowDelay="500"
    EnableShadow="true" HideDelay="1"
    Position="TopRight" ShowCallout="false" RelativeTo="Element" OnAjaxUpdate="OnAjaxUpdate"
    Width="372px" Height="330px" OnClientBeforeShow="clientBeforeShow">
</telerikAjax:RadToolTipManager>

4 Answers, 1 is accepted

Sort by
0
Svetlina Anati
Telerik team
answered on 05 May 2011, 11:45 AM
Hi Guido S,

 When you change the RadGrid's page, you actually display new records which have different target control ID. In order to achieve the desired behavior, you should update the RadToolTipManager's TargetControls collection. I assume that in your case the RadToolTipManager stays with the old values when the page is changed.

One possible solution is to clear the TargetControls collection in the RadGrid's PageIndexChanged event handler by adding the following code:

  protected void RadGrid1_PageIndexChanged(object source, GridPageChangedEventArgs e)  
    {  
        RadToolTipManager1.TargetControls.Clear();  
    } 

Note, also, that in case you have ajaxified the grid, you should also make sure that you update the tooltip manager when you update the grid.

A sample demo is available below:

http://demos.telerik.com/aspnet-ajax/tooltip/examples/targetcontrolsandajax/defaultcs.aspx

In case this does not help, please prepare a sample, fully runnable reproduction project (including DB, if needed), open a new support ticket and send it to me. Once I receive it, I will modify it in order to meet your requirements.

Best wishes,
Svetlina
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Guido S
Top achievements
Rank 1
answered on 05 May 2011, 11:59 AM
Hey Svetlina,

Thanks for the fast reply.

Well yea, the tooltip gets updated in the OnAjaxUpdate event.

protected void OnAjaxUpdate(object sender, ToolTipUpdateEventArgs args)
{
    if (this.EnableMouseOver)
    {
        UserControls_bla_TooltipControl ctrl = (UserControls_bla_TooltipControl )Page.LoadControl("page");
        
        var blaView= this.BlaViews.First(i => i.Id.ToString() == args.Value);
 
        NameView mockView = new NameView
                                               {
                                              stuff
                                               };
        ctrl.DataSource = mockView;
        ctrl.DataBind();
        tooltipManager.UpdatePanel.ContentTemplateContainer.Controls.Clear();
        tooltipManager.UpdatePanel.ContentTemplateContainer.Controls.Add(ctrl);
    }
}

Same for the clearing.
  protected void name_PageIndexChanged(object sender, Telerik.Web.UI.GridPageChangedEventArgs  e)
   {     
  tooltipManager.TargetControls.Clear();
}

But ill look at it some more.
0
Accepted
Svetlina Anati
Telerik team
answered on 06 May 2011, 02:07 PM
Hi Guido,

What  I meant by saying "Note, also, that in case you have ajaxified the grid, you should also make sure that you update the tooltip manager when you update the grid."   in my previous reply was to make sure that you update the RadToolTipManager when you update the grid. This means to put in the same update panel as the grid or add it to ajax manager settings (I do not recommend to use RadAjaxManager in this scenario because of known problems  with nested update panels).

You can test my assumption by disabling all the AJAX related code and test whether with plain postbacks the issue disappears. If it does, the problem is indeed that you do not update the manager when you update the targets.

If removing AJAX still does not solve the issue, please, send me a sample, working code and I will examine it for you.

 Regards,
Svetlina
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Guido S
Top achievements
Rank 1
answered on 09 May 2011, 02:21 PM
Hey Svetlina,
 
Indeed, the only thing i had to do was adding the RadToolTipManger to the UpdatedControls of the RadAjaxManager.
Kinda makes a lot of sense.

Anyways, its working and thanks for your help!

Kind regards,

Guido
Tags
ToolTip
Asked by
Guido S
Top achievements
Rank 1
Answers by
Svetlina Anati
Telerik team
Guido S
Top achievements
Rank 1
Share this question
or