ExpandCollapse calls disabling ToolTip in RadGrid?

7 posts, 1 answers
  1. Boris
    Boris avatar
    275 posts
    Member since:
    Oct 2012

    Posted 25 Feb 2013 Link to this post

    I've cookbooked a couple of tooltip popups based on your demos.   These appear when I hover over one cell of the RadGrid. The original one was based on http://www.telerik.com/community/code-library/aspnet-ajax/grid/integrating-radtooltipmanager-with-radgrid.aspx.  This was enough for a simple display grid with no filtering or paging.  

    When I tried to implement a similar scheme on my far more complex main grid, the popup started displaying data for the wrong record.
    This was solved by adding the  RadToolTipManager1.TargetControls.Clear() call to the ItemCommand.  This is fired for the Filter, Page, Sort, and RebindGrid commands.

    Everything is working as desired now except for one matter.  

    This grid is a standard header/detail arrangement.  If I expand any of the details, the popup stops working.

    Suggestions?

  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3595 posts

    Posted 26 Feb 2013 Link to this post

    Hi Boris,

    You need to clear the targets only when the data in the main grid is changed, not in all cases when the ItemCommand event handler is called. You can see an example here. The ItemCommand event is raised for expanding/collapsing a hierarchical table, so you clear the targets for the tooltip manager and this is why there should be no popups on the page.


    Regards,
    Marin Bratanov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Boris
    Boris avatar
    275 posts
    Member since:
    Oct 2012

    Posted 26 Feb 2013 Link to this post

    I'm sorry but I'm afraid I don't understand your answer at all.

    First of all that example isn't really useful since has no filtering or details.

    Second, if I cut back the item command part to only fire on Sorts and Pages, aside from the fact that my popups no long have the right data, it still disables them entirely if I expand/contract.  In any case, the clear is only called in one place, in ItemCommand, and it is not being called on ExpandCollapse.
  5. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3595 posts

    Posted 27 Feb 2013 Link to this post

    Hi Boris,

    I build a sample test by following the demo I linked and the basic hierarchy demo of the grid. You can find attached my sample that seems to work fine on my end. You will also find a video that shows the event should be fired. I advise that you examine this and try to find the difference in your case that is causing the problem. You should also add a breakpoint in the ItemDataBound event to see when/if you re-add tooltips when needed.


    All the best,
    Marin Bratanov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  6. Boris
    Boris avatar
    275 posts
    Member since:
    Oct 2012

    Posted 27 Feb 2013 Link to this post

    Still no good.  It's still dying when I expand a detail.  Could it be because I'm not using a ItemTemplate control?
    Here's my ItemDataBound code.  

    if (e.Item.OwnerTableView.Name == "TicketHeader")
    {
      if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem)
      {                                                                
         GridDataItem ditem = (GridDataItem)e.Item;
         var l = (GridTableCell)ditem["Description"];
         if (l != null)
         {
              if (!IsTooltify(l.ClientID))
                 RadToolTipManager1.TargetControls.Add(l.ClientID, ditem["TicketId"].Text, true);
         }                 
       }
    }


    One other thing I just noticed.  Your page has a different !DocType declaration than mine.  All I have is <!DOCTYPE html> (which means HTML5.  Right?).  I did try your version but no change.

  7. Answer
    Marin Bratanov
    Admin
    Marin Bratanov avatar
    3595 posts

    Posted 01 Mar 2013 Link to this post

    Hello Boris,

    The ultimate purpose of the doctype is to tell the browser how to interpret the content. Put simply - to use standards mode or quirks mode. The best case scenario is to use standards mode, of course. With valid markup both doctypes will induce the same browser mode.

    Back to the grid - you can use the ItemCreated event because it will be fired with each postback (see the grid's event sequence here) while the ItemDataBound event will not be fired for the main table when you expand a child table, the main one has already been bound.
    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item.OwnerTableView.Name == "TicketHeader")
        {
            if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem)
            {
                GridDataItem ditem = (GridDataItem)e.Item;
                var l = (GridTableCell)ditem["CompanyName"];
                if (l != null)
                {
                    RadToolTipManager1.TargetControls.Add(l.ClientID, ditem.OwnerTableView.DataKeyValues[ditem.ItemIndex]["CompanyName"].ToString(), true);
                }
            }
        }
    }

    <telerik:RadGrid ID="RadGrid1" ShowStatusBar="true" OnItemCreated="RadGrid1_ItemCreated"
        OnItemCommand="RadGrid1_ItemCommand" DataSourceID="SqlDataSource1" runat="server"
        AutoGenerateColumns="False" PageSize="7" AllowSorting="True" AllowMultiRowSelection="False"
        AllowPaging="True" GridLines="None" AllowFilteringByColumn="true">
        <GroupingSettings CaseSensitive="false" />
        <PagerStyle Mode="NumericPages"></PagerStyle>
        <MasterTableView DataSourceID="SqlDataSource1" DataKeyNames="CustomerID, ContactName, CompanyName"
            AllowMultiColumnSorting="True" Name="TicketHeader">


    Regards,
    Marin Bratanov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  8. Boris
    Boris avatar
    275 posts
    Member since:
    Oct 2012

    Posted 01 Mar 2013 Link to this post

    Works perfectly.

    (At the risk of complaining I think the documentation needs to be updated a bit.  Every example I've seen so far has used ItemDataBound to populate the TargetControls collection.)

    Thanks.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017