RadGrid in ToolTip on RadGrid

12 posts, 0 answers
  1. Stefan Stanescu
    Stefan Stanescu avatar
    11 posts
    Member since:
    Nov 2009

    Posted 30 Nov 2009 Link to this post

    Hi all

    The page I'm doing is a little complicated but I will try to explain what I need to achieve.
    1. On the page there is an UpdatePanel ("upTimeRegs") with a RadGrid, where each row has an ID and a link.
    2. When the mouse is over a link, a ToolTip ("ToolTipManager") should appear with contents based on the row's ID.
    3. The content of the ToolTip is a user control ("ucTimeRegistrations") with another RadGrid ("RadGridTimeRegistrations") which has it's data bound in the NeedDataSource event handler
    4. In the second RadGrid one of the columns is a RadComboBox. For each RadComboBox OnSelectedIndexChanged the main RadGrid should be updated

    The problems I have:
    1. The ToolTip is loaded fine the first time the mouse is over a link, but then when I hover a second link the content of the tooltip is not changed because the NeedDataSource event is not triggered.

    2. The main RadGrid is not being updated when the selected index of a combobox is changed.

    Here is some of the code I'm using:
    protected void ToolTipManager_OnAjaxUpdate(object sender, ToolTipUpdateEventArgs args) 
        Control ctrl = Page.LoadControl("~/UserControls/ucTimeRegistrations.ascx"); 
        args.UpdatePanel.ContentTemplateContainer.Controls.Add(ctrl); 
        ucTimeRegistrations TimeRegistrations = (ucTimeRegistrations)ctrl; 
        TimeRegistrations.TaskID = Convert.ToInt32(args.Value); 
     
     
     
    public partial class ucTimeRegistrations : UserControl 
        public int TaskID; 
        protected void Page_Load(object sender, EventArgs e) 
        { 
        } 
     
        protected void RadGridTimeRegistrations_NeedDataSource(object  source, GridNeedDataSourceEventArgs e) 
        { 
            RadGTimeRegistrations.DataSource = TimeRegistrationHandler.GetTimeRegistrationsFromDB(TaskID); 
        } 
     
        protected void RadComboBoxActivity_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e) 
        { 
            RadComboBox rcbActivity = (RadComboBox)sender; 
            GridDataItem Row = (GridDataItem)rcbActivity.Parent.Parent; 
            if (Row != null
            { 
                int TimeRegistrationID = Convert.ToInt32(Row["TimeRegistrationID"].Text); 
                int ActivityID = Convert.ToInt32(e.Value); 
                TimeRegistrationHandler.UpdateTimeRegistration(TimeRegistrationID, ActivityID); 
                     
                UpdatePanel upTimeRegs = (UpdatePanel) FindControlRecursive(Page, "upTimeRegs");
                upTimeRegs.Update(); 
            } 
        }

        private Control FindControlRecursive(Control rootControl, string Id)
        {
            if (rootControl.ID == Id)
                return rootControl;
            foreach (Control childControl in rootControl.Controls)
            {
                Control foundControl = FindControlRecursive(childControl, Id);
                if (foundControl != null) return foundControl;
            }
            return null;
        }
     


    Thanks,
    Stefan

  2. Stefan Stanescu
    Stefan Stanescu avatar
    11 posts
    Member since:
    Nov 2009

    Posted 01 Dec 2009 Link to this post

    Me again.

    I fixed the first problem by rebinding the RadGrid in the PreRender event of the user control.
    I couldn't rebind it in the PageLoad because it would prevent me from finding the item i selected in a combobox.

    protected void Page_Load(object sender, EventArgs e) 
        this.PreRender+=OnPreRender; 
     
    protected void OnPreRender(object sender, EventArgs e) 
        RadGridTimeRegistrations.Rebind(); 

    One more to go :)


  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Stefan Stanescu
    Stefan Stanescu avatar
    11 posts
    Member since:
    Nov 2009

    Posted 02 Dec 2009 Link to this post

    There, I fixed it!


    I needed to rebind the main RadGrid on the SelectedIndexChanged event before updating the UpdatePanel. I was missing the obvious.

    One more quick tip: I had to place the RadToolTipManager outside of the UpdatePanel, because it was hiding after each selected index change.

    Hope this will help others as well :)

    All the best,
    Stefan
  5. Kevin
    Kevin avatar
    16 posts
    Member since:
    Nov 2007

    Posted 02 Dec 2009 Link to this post

    Stefan,

    I just wanted to say thanks for coming back and posting your findings - this will help me with a project I'm starting!

    --Kdc
  6. Stefan Stanescu
    Stefan Stanescu avatar
    11 posts
    Member since:
    Nov 2009

    Posted 04 Dec 2009 Link to this post

    I've been trying to determine what was causing my ToolTips not to be updated when I was sorting the main RadGrid and it seems like the small tip I've written in the previous post is kind of useless.
    Actually, I had no choice but to place the RadToolTipManager back in the UpdatePanel with the RadGrid to solve this problem.

    So here's my next problem: how do I make the ToolTip visible after postbacks, with the exact same contents it had before?


    Stefan
  7. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 09 Dec 2009 Link to this post

    Hello Stefan,

    Have you tried setting the UpdatePanel wrapping the grid and the tooltip UpdateMode property to Conditional and see if it makes any difference?


    All the best,
    Iana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  8. Stefan Stanescu
    Stefan Stanescu avatar
    11 posts
    Member since:
    Nov 2009

    Posted 10 Dec 2009 Link to this post

    Hi Iana,

    Yes the UpdateMode is set to Conditional.

    Just to make things clear I am using the Q2 2008 version of the controls.

    Right now when the mouse is over a link in the main RadGrid the ToolTip is displayed correctly. Then if I click a button or change the selected index of a RadComboBox inside the ToolTip the main RadGrid gets updated as it should, but the ToolTip is no longer visible. The ToolTipManager has ManualClose="true" and Sticky="true" so I would like it to stay in place until I close it. I think this is the same as HideEvent="ManualClose" in the new version of RadToolTipManager.

    I just need to know if this is the expected behavior of the RadToolTips. If so, what would be the best approach to make the ToolTip visible again? (otherwise, it's just a problem with my code and I'll post a solution as soon as I find it)

    Best regards,
    Stefan

  9. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 11 Dec 2009 Link to this post

    Hello Stefan,

    I tried follwoing your scenario and prepared a sample project for you. Could you please check it out and let me know what differs in your case?

    Regards,
    Iana
    the Telerik team


    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  10. Stefan Stanescu
    Stefan Stanescu avatar
    11 posts
    Member since:
    Nov 2009

    Posted 11 Dec 2009 Link to this post

    Hello Iana,

    Thanks for your reply!

    I tried the sample project but unfortunately I didn't find a solution for my problem.
    I changed the RadGrid1_NeedDataSource event just a little bit, so we get new data every time we rebind the RadGrid (just added a date stamp to each row).

    for (int i = 0; i < 50; i++) 
        table.Rows.Add(i, "Item" + i.ToString() + " " + DateTime.Now.ToString()); 

    Then I added to the RadComboBox1_SelectedIndexChanged event the following code:

    UpdatePanel UpdatePanel1 = (UpdatePanel)Page.FindControl("UpdatePanel1"); 
    RadGrid RadGrid1 = (RadGrid)UpdatePanel1.ContentTemplateContainer.FindControl("RadGrid1"); 
    RadGrid1.Rebind(); 
    UpdatePanel1.Update(); 

    This simulates the behavior of my application, because I need to update the data inside the RadGrid using the ToolTip.

    The call to UpdatePanel1.Update(); is necessary because the RadToolTipManager creates it's own UpdatePanel (therefore we have one UpdatePanel inside another) and this is the only way that I know to update the outer UpdatePanel from a control inside the inner UpdatePanel.

    With these changes the behavior is almost the same as with my application: the RadGrid gets updated but the ToolTip disappears.

    There is an extra problem with this approach in the sample project, which I don't have in my app (probably because in my case the RadComboBox is inside the ItemTemplate of a GridTemplateColumn from a RadGrid): the RadComboBox1_SelectedIndexChanged event gets triggered twice every time - once when I select an item and once more probably because of UpdatePanel1.Update();
    But as I said, this is only in this sample project.

    I hope I didn't get you confused.

    Best regards,
    Stefan
  11. Stefan Stanescu
    Stefan Stanescu avatar
    11 posts
    Member since:
    Nov 2009

    Posted 11 Dec 2009 Link to this post

    I have no idea why the background is gray on the previous post XD

    <div style="color:Red;">
    I wonder if the editor has also support for html.
    <div>

    Update: seems not
  12. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 14 Dec 2009 Link to this post

    Hi Stefan,

    Thank you for the additional information provided.

    I followed you description and was able to replicate the unexpected behavior on my side. In order to overcome this issue I suggest that you first close the tooltip when item is selected from the combobox and then update the grid. Please check the attached for additional details and let me know if this works for you. 


    All the best,
    Iana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  13. Stefan Stanescu
    Stefan Stanescu avatar
    11 posts
    Member since:
    Nov 2009

    Posted 26 Jan 2010 Link to this post

    YES!!!

    I finally found out how to make the RadToolTip reappear after a postback.
    It turns out that all I had to do was to set the RadToolTip's VisibleOnPageLoad property to "true".

    Thanks for your great support! Problem solved!

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